Xport
A command line tool written in Kotlin and Micronaut that converts an X/Twitter data export into Hugo markdown files, preserving the original timestamps and media. I used it to bring my old tweets over to the microblog on this site.
Xport is a command-line tool built with Kotlin and Micronaut that processes Twitter data exports, converting them from JavaScript format to standard JSON and then to Hugo-compatible Markdown.
Features
- Converts Twitter archive data from JavaScript format to JSON
- Transforms tweets into Hugo-compatible Markdown files
- Preserves tweet media (images, videos)
- Maintains original tweet timestamps
- Provides verbose output option for detailed processing information
Installation
Prerequisites
- Java 21 or higher
- Gradle (for building from source)
Building from Source
-
Clone the repository:
git clone https://github.com/yourusername/xport.git cd xport -
Build the project:
./gradlew build -
Create a native executable (optional):
./gradlew nativeCompile
Usage
xport [OPTIONS] <archive-directory> <output-directory>
Arguments
<archive-directory>: Path to the Twitter archive directory (containing the “data” folder)<output-directory>: Path to the output directory (must exist and be empty)
Options
-a, --author: Author name for generated markdown files-f, --filter-replies: Filter out tweets that are replying to another tweet-m, --media-path: Path to be appended to media URLs in generated markdown files-h, --help: Show help message and exit-v, --verbose: Enable verbose output-V, --version: Show version information and exit
Examples
Basic usage:
xport ~/Downloads/twitter-archive ~/Documents/my-tweets
With verbose output:
xport -v ~/Downloads/twitter-archive ~/Documents/my-tweets
Specifying an author and filtering out replies:
xport -a "John Doe" -f ~/Downloads/twitter-archive ~/Documents/my-tweets
Setting a custom media path:
xport -m "/images/tweets" ~/Downloads/twitter-archive ~/Documents/my-tweets
Using multiple options:
xport -v -a "John Doe" -m "/images/tweets" -f ~/Downloads/twitter-archive ~/Documents/my-tweets
How It Works
Xport processes your Twitter archive through a pipeline of tasks:
- Copies the tweet.js file from the archive
- Converts the JavaScript format to JSON
- Transforms the JSON to Hugo-compatible Markdown
- Parses and formats tweet timestamps for filenames and Hugo front matter
- Expands shortened Twitter URLs (t.co links) to their original full URLs
- Converts media URLs to proper markdown image references or HTML video tags
- Adds reply context with links to original tweets for replies
- Applies custom author name and media paths if provided
- Copies media files (images, videos) from the archive
- Cleans up temporary files
The resulting Markdown files include Hugo front matter with the tweet’s timestamp and content, making them ready to use with Hugo static site generator.
Output Format
Each tweet is converted to a Markdown file with the following structure:
---
title: YYYY-MM-DDTHH-MM
date: YYYY-MM-DDTHH:MM:SS+0000
author: Your Name # Customizable with the -a, --author option
showtoc: false
comments: true
---
Tweet content goes here
 # Path prefix customizable with the -m, --media-path option
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.