So! Trying to get off Twitter? OR maybe just want to explore your data? I wrote a script that turns your Twitter archive into a default readable page. Twitter offers you a page for this, but it breaks threads, so I used ChatGPT to reformat the data and build a dead simple web builder. I'll share the loose structure of how I got ChatGPT to do this, but the other files here are the final scripts so that you don't have to fiddle with tweaking them yourself.
- Download your data here: https://twitter.com/settings/download_your_data (it usually takes a day or two for this to be ready)
- Feed ChatGPT 4 (not 3.5) some of the sample tweets from ARCHIVE/tweets.js and have it generate types
- Instruct GPT-4 to create a script which merges tweets into a tree structure, preserving the parent-child relationship for threads, and throw away extra unnecessary fiels
- Instruct GPT-4 to create an HTML page using that script
- Open and enjoy!
Technically you don't need to filter out the data, but it makes the process faster and easier to work with post-transformation.
- My script uses NodeJS. You can ask GPT-4 to generate it in any language, of course. But I used NodeJS.
- For Mac and Linux, I recommend NVM: https://medium.com/geekculture/how-to-install-node-js-by-nvm-61addf4ab1ba
- There is an equivalent for Windows here: https://github.com/coreybutler/nvm-windows
- You'll need ChatGPT 4 to generate code. 3.5 can work, but is error prone. 4 is nearly perfect, though can still make some errors. Of course, you can just tweak these scripts here instead.
- I recommend a capable code editor like VS Code for viewing and editing code files.
Assuming you don't mess around with creating your own ChatGPT script, here is how you use this gist.
- Download your archive
- Copy your tweets.js from ARCHIVE/data/tweets.js to ARCHIVE/tweets.json
- Edit tweets.json to delete the leading
window.YTD.tweets.part0 =
. Once you do that, your tweets.json file is now valid JSON - Copy my compile.js script to ARCHIVE/compile.js
- Run compile.json with Node (run Node from your command line of choice). If you don't know how to use a command line:
- Mac OS X - Terminal - https://support.apple.com/guide/terminal/execute-commands-and-run-tools-apdb66b5242-0d18-49fc-9c47-a2498b7c91d5/mac
- Windows - Command Prompt (or PowerShell) - https://www.digitalcitizen.life/command-prompt-how-use-basic-commands/
- The previous command generates a formatted_tweets.json file. Open it and add
window.tweets =
, then save the file asformatted_tweets.js
. This is the file that our basic browser will use. - Copy my compile.html file to ARCHIVE/compile.html and double click it to open it. If you've correctly done everything, compile.html will pull the formatted_tweets.js file from the same directory, and show you a view that looks like this:
You of course can tweak any of the scripts, run them through ChatGPT-4, ask for modifications, and so on. I set up mine in a way that has enough utility for my needs (copying them out and structuring them), but you can now use your dataset to generate markdown files, or upload somewhere, or whatever.