Convert Markdown and long-form articles into optimized X (Twitter) threads, LinkedIn carousels, and Threads drafts.
md-to-thread is a lightweight, zero-dependency CLI tool and Node.js library that parses long Markdown text or blog posts and breaks them into clean, platform-optimized social media threads with natural sentence boundaries and automated numbering.
Part of the PostReady.org open-source content repurposing toolkit.
- Natural Boundary Splitting: Splits on paragraph and sentence boundaries without cutting mid-sentence.
- Social Presets: Built-in limits for X Standard (280), Threads (500), Bluesky (300), LinkedIn (3000), and X Premium (4000).
- Custom Thread Numbering:
1/N,1/N,[1/N],(1/N), or suffix formats. - Clean Formatting: Strips noisy Markdown headers, raw links, and horizontal rules into clean social copy.
- Flexible I/O: Run on files, pipe via
stdin, or export as formatted terminal cards, plain text (---), or structured JSON. - Zero Runtime Dependencies: Native Node.js ESM.
Run directly with npx:
# Split a markdown file with default X limit (280 chars)
npx md-to-thread article.md
# Pipe from cat or git diff
cat blog-draft.md | npx md-to-thread
# Target Threads (500 chars) with thread emoji counter
npx md-to-thread README.md --limit threads --format thread
# Output clean JSON for automation pipelines
npx md-to-thread post.md --json > thread.jsonOr install globally:
npm install -g md-to-threadUSAGE:
$ md-to-thread <file.md> [options]
$ cat article.md | md-to-thread [options]
OPTIONS:
-l, --limit <num|preset> Max characters per post (default: 280)
Presets: x-standard (280), threads (500),
bluesky (300), linkedin (3000), x-premium (4000)
-f, --format <style> Thread counter style: fraction (1/N),
thread ( 1/N), brackets ([1/N]), parens ((1/N)), suffix
--no-counter Disable thread numbering
--raw Do not clean markdown syntax
--json Output structured JSON array
--plain Output plain text separated by '---'
-h, --help Show help
-v, --version Show version
Install locally:
npm install md-to-threadUsage in Node.js / TypeScript:
import { splitMarkdownToThread } from 'md-to-thread';
const markdown = `
# Building in Public
Shipping open-source tools is the best distribution engine for SaaS founders.
When you solve real developer problems with lightweight CLI utilities, adoption follows naturally.
`;
const thread = splitMarkdownToThread(markdown, {
limit: 280,
counter: true,
counterFormat: 'thread'
});
console.log(thread);
/*
[
{
index: 1,
total: 2,
text: ' 1/2\n\nBuilding in Public\n\nShipping open-source tools...',
charCount: 165,
remainingChars: 115
},
...
]
*/This tool was created by PostReady.org — an AI content repurposing studio that turns blog articles, podcasts, and developer notes into editable X threads, LinkedIn posts, and newsletter drafts.
Check out our free web tools:
MIT © eco-null