# What is tweets.js and why isn’t it JSON?

> tweets.js is the file in your X archive’s data folder that holds your posts. It is JSON wrapped in a JavaScript assignment — window.YTD.tweets.part0 = [ … ] — so the bundled viewer can load it, which is why JSON tools reject it. TweetArchive strips that prefix (without running the code), parses the JSON, and shows it as a timeline.

## Step by step

1. **Find the file.** Look in the archive’s data folder for tweets.js (sometimes tweet.js, or tweets-part1.js, tweets-part2.js for big archives).
2. **Understand the prefix.** Everything before the first [ is a JavaScript assignment. The rest is JSON.
3. **Skip the manual work.** Open the whole ZIP in TweetArchive; it reads every part in order and merges them.
4. **Export clean data.** Download posts as CSV or JSON with IDs kept as text.

Open the tool: https://tweetarchive.fyi/#app (runs in your browser; the ZIP is not uploaded; free preview, $19 one-time for everything).

## Honest limitations

- There is no official public specification of the archive format that we could read; TweetArchive follows what several independent parsers document and discovers file names instead of assuming one layout.
- Some archives omit @usernames for DM partners; those people appear as a numeric user ID.
- TweetArchive is not affiliated with X Corp. and does not log in to X for you.
- Post IDs are larger than JavaScript can store as numbers, so they must be kept as strings (id_str). TweetArchive does that.

## FAQ

### Why is it .js and not .json?

So the offline viewer page can load it with a script tag. The data itself is JSON after the prefix.

### What fields does a post have?

Parsers document fields like id_str, full_text, created_at, favorite_count, retweet_count, entities, and in_reply_to_status_id_str.

### Can I just delete the prefix?

Yes, deleting text up to the first [ usually gives valid JSON. Never run the file as code in a tool you don’t trust.

### What about direct-messages.js?

Same pattern: window.YTD.direct_messages.part0 = [ … ].

## Related

- [How to download your official X archive](https://tweetarchive.fyi/download-x-archive.md)
- [Privacy](https://tweetarchive.fyi/privacy/)

## Sources

- [The Verge: How to download an archive of your Twitter data (updated Nov 14, 2022)](https://www.theverge.com/23453703/twitter-archive-download-how-to-tweets)
- [Ars Technica: How to download a backup copy of your Twitter data (Oct 28, 2022)](https://arstechnica.com/information-technology/2022/10/how-to-download-a-backup-copy-of-your-twitter-data-or-deactivate-your-account/)
- [twitter-archive-parser by Tim Hutton (GitHub)](https://github.com/timhutton/twitter-archive-parser)
- [alkihis/twitter-archive-reader: file structures](https://github.com/alkihis/twitter-archive-reader)

TweetArchive is an independent tool made by Cedano Labs LLC. It is not affiliated with, endorsed by, or sponsored by X Corp. “X” and “Twitter” are trademarks of X Corp., used here only to describe the archive format the tool reads. TweetArchive is not a forensic lab or a legal service, and its exports are not certified evidence.
