#
prompt2mdA Markdown Magic

Open source, Apache-2.0

Fold any text into token‑optimized Markdown

Other tools cut and hope. prompt2md folds: smaller Markdown, honest token numbers, and the byte-exact original back on demand.

Your prompt
Token-optimized Markdown
Press Fold to run this through the real pipeline.
Runs live against this deployment. Nothing is stored on our side.

Watch it fold, chapter one

332tests, green on Linux & Windows
0telemetry, accounts, or uploads
6tools wired by one command
100%of savings figures reproducible

[ 01 / 06 ]The Fold

Everything else cuts. This folds.

The distinction is not stylistic. It is the difference between a transformation you can undo and one you cannot.

retrieve_original: byte-exact

Scroll ↓ — this is your pasted text.

Fold. Structure and duplication come out. Nothing is discarded.

Unfold. retrieve_original hands back the exact source bytes.

The story is the architecture: the original is stored, content‑addressed, before anything is transformed.

Cutting

  • Truncates to fit a window
  • Drops the middle and hopes
  • Summaries replace the source
  • Savings are estimated, or unstated
  • The detail is gone for good

Folding

  • Structures, dedupes, then summarizes only what is safe
  • Head and tail stay verbatim, because models attend to them most
  • Tables, code, and headings are never summarized
  • Every figure comes from a real run you can repeat
  • retrieve_original returns the exact source bytes

[ 02 / 06 ]The Mechanism

How a document becomes cheap context

Five stages. The interesting one is the third: the pipeline checks its own work and escalates when the cheap engine got it wrong.

  1. Sniff

    Cheap byte-level probes read the content itself, never the file extension.

  2. Route

    Fast path for text-layer PDFs, HTML, Office, CSV. High-fidelity path for scans and complex tables.

  3. Escalate

    The fast path's output is inspected for damage. Degraded tables or low yield trigger a re-run on the heavy engine.

  4. Optimize

    Boilerplate, navigation chrome, signatures, and duplicated passages come out. Structure stays.

  5. Layout

    Stable content first, volatile last, provider-specific cache breakpoints in between.

[ 03 / 06 ]The Proof

Built for context budgets, not demos

Token cost is an output, not a footnote

Every conversion returns a report: tokens in, tokens out, compression ratio, per-section costs, and the effective cost of each repeat call under your provider’s cache pricing. Set a budget and it is enforced, not suggested.

Lossless by construction

Originals are stored content-addressed before anything is transformed. Summarized sections carry p2md:src anchors that resolve to exact bytes.

Dual-engine routing

~0.6 s fast path for most inputs; TableFormer and OCR only when the content proves it needs them.

Cache-aware layout

Sections are ordered so prompt caches hit. Repeat calls can cost a fraction of the first one.

Works with nothing installed

No API key, no sidecar, no account. With zero configuration you get deterministic cleanup and honest numbers; add an LLM gateway and the same pipeline restructures far more aggressively. Text input never hard-fails.

[ 04 / 06 ]The Surfaces

Four surfaces, one pipeline

The same engine behind a command line, an MCP server, an agent skill, and this studio.

Command line
prompt2md convert ./contract.pdf -b 6000
prompt2md compress big-context.md -b 4000
prompt2md batch "docs/**/*.html" -d out/ --watch
prompt2md retrieve "p2md:src=<id>#<start>-<end>"
MCP server
{
  "mcpServers": {
    "prompt2md": {
      "command": "node",
      "args": ["<repo>/packages/hermes-mcp/dist/bin.js"]
    }
  }
}
Agent skill
cp -r packages/skill/prompt2md ~/.claude/skills/

# then, in any conversation:
/prompt2md convert this thread to markdown

[ 05 / 06 ]The Access

One command wires every tool you use

Detects what is installed, backs up every config before touching it, and is safe to re-run. Preview it first with --dry-run.

setup
git clone https://github.com/Hotragn/Prompt2MD.git prompt2md
cd prompt2md && pnpm install && pnpm build
pnpm setup
  • Claude Code
  • Claude Desktop
  • Cursor
  • Windsurf
  • Gemini CLI
  • Codex CLI
  • any MCP client

Model providers are independent of the tool: point P2MD_LITELLM_BASE_URL at any OpenAI-compatible endpoint. Claude, GPT, Gemini, Grok, Kimi, or a local model.

[ 06 / 06 ]The Invitation

See it fold something of yours

Paste a rambling prompt, a contract, or an email thread. You will get clean Markdown, a number you can check, and a way back to the original.