tweet-to-md
v1.0.5
Published
Converts a Tweet to Markdown for LLMs.
Readme
tweet-to-md
Converts a Tweet to Markdown for LLMs.
Features
- ✅ supports all tweet types
- ✅ embed tweets as context for LLMs
- ✅ zero deps
- ✅ unit tests
- ✅ cli
- ✅ works without an API key
- ✅ free
Install
npm install tweet-to-mdUsage
import { getTweet, tweetToMarkdown } from 'tweet-to-md'
// fetch the tweet by id and then convert it to markdown
const tweet = await getTweet('1324595039742222337')
if (tweet) {
const markdown = tweetToMarkdown(tweet)
console.log(markdown)
}CLI
npx -y tweet-to-md 1324595039742222337Usage: tweet-to-md [options] <tweetId>
Converts a Tweet to Markdown
Arguments:
tweetId Tweet ID
Options:
-h, --help display help for commandExamples
| Tweet Type | Example Tweet | Markdown Output | Supported? | Notes | | --------------- | ------------------------------------------------------------------------------- | -------------------------------------------- | ---------- | ------------------------------- | | Text | 1324595039742222337 | example | ✅ | | | Image | 1466447129178783744 | example | ✅ | | | Multiple Images | 1464100253297168403 | example | ✅ | | | Image Card | 1489025536714321920 | example | ✅ | | | Quote Tweet | 1507146276416098307 | example | ✅ | | | GIF | 1932187590955823235 | example | ☑️️ | poster image only, no animation | | Video | 1990435817844887586 | example | ☑️️ | poster image only, no video | | Poll | 1502069843721347073 | example | ☑️️ | poll choices not displayed | | Article | 2034257912973963374 | example | ☑️️ | article content not displayed |
Notes
- fetching tweets uses twitter's public syndication api, so it's free and no API key is needed
- it outputs Github-Flavored Markdown (GFM) which is well-supported by LLMs
- tweet fetching and rendering is loosely based on vercel/react-tweet
License
MIT © Travis Fischer
Support my OSS work by following me on X
