If you're like me and you started Twitter when you were 14 in 2011, you're probably a different person now than you were back then. This script helps you clean up your Twitter/X timeline by deleting everything before a certain date — and keeping everything after it.
It is a browser DevTools console script. There is no app to install and no API key to set up. You paste it into the console on your own logged-in X profile, pick a cutoff date, and it deletes your posts older than that date.
The script runs in your browser using your existing X session. It only acts on your posts. Tweets on or after the cutoff date (local midnight) are kept. Anything older is deleted.
There are two modes:
- Archive mode — pick
data/tweets.jsfrom an X data archive. This is the reliable way to reach old tweets. - Timeline mode — scrolls your profile page and deletes what is currently loaded. X only shows a limited number of recent posts this way, so old tweets often never appear. Use archive mode if your cutoff is years back.
- Log in to x.com in your browser.
- Open your profile with replies:
https://x.com/YOUR_USERNAME/with_replies - Open DevTools → Console (
Cmd+Option+Jon Mac,F12elsewhere). Chrome may ask you to typeallow pastingthe first time. - Copy the entire contents of
delete-before-date.js, paste it into the console, and press Enter. - Enter a cutoff date as
YYYY-MM-DD(for example2018-01-01). Posts on or after that date are kept. - Confirm, then choose a mode:
- OK = Archive mode (select
data/tweets.jsfrom your unzipped archive) - Cancel = Timeline mode (only posts currently visible on the page)
- OK = Archive mode (select
Keep the tab open while it runs.
To stop early, type this in the console:
STOP_DELETE = true- On X, go to Settings → Your account → Download an archive of your data.
- Wait until X says the archive is ready (this can take hours).
- Download and unzip it.
- When the script asks for a file, choose
data/tweets.js.
X limits how many posts you can delete in a window. That limit is on their side and cannot be bypassed.
When the script hits a rate limit, it waits until X's reset time and then continues automatically. You may see a pause of several minutes. Leave the tab open and let it resume.
If you run this over a large archive, expect it to take a while.
This is provided as-is, with no warranty. Use it at your own risk.
Deletions are permanent. You are responsible for the cutoff date you enter, for confirming the prompts, and for anything that happens to your account. The authors are not responsible for lost posts, account restrictions, rate-limit lockouts, X policy enforcement, or any other outcome.
This script is meant only for your own account. Do not use it on anyone else's.