Format
What it is
Section titled “What it is”One call that takes a Markdown document and returns it formatted: one list marker, one emphasis style, aligned tables, no trailing spaces, one line ending. The response also says whether anything changed.
When to use it
Section titled “When to use it”- Your agent’s cue: it is about to save, commit or publish Markdown it wrote or edited, and the project expects a consistent style.
- You’ll reach for it when several people and agents edit the same documents and every diff is half formatting noise.
Real use cases
Section titled “Real use cases”Building without a terminal
Section titled “Building without a terminal”You are building a content tool in Lovable where an agent drafts articles in Markdown and saves them to your database. Before saving, a backend function sends the draft to MarkdownScribe and stores the formatted version. When the agent edits one cell of a table, the whole table comes back aligned, not just that cell, so the stored document always reads the same way in the editor.
Working with a coding agent
Section titled “Working with a coding agent”Your coding agent edited a folder of documentation with .md and .mdx files side by side. mdscribe format docs/ --write formats every .md file and skips the .mdx ones, because formatting MDX as Markdown would change its code. Sent directly to the API, an MDX document is refused with unsupported_format and nothing is charged.
In a pipeline
Section titled “In a pipeline”A CI step runs mdscribe format docs/ --check. When a file would change, the command exits with code 8 and the build fails, the same convention as other formatters’ check modes. Contributors run the same command with --write locally and push again.
Why through the API
Section titled “Why through the API”- The same output everywhere. The rules are fixed on our side, so a document formatted from a browser-based editor, from a coding agent and from CI comes out identical.
- Code stays as written. Fenced code blocks, HTML blocks and the YAML of the frontmatter are left alone. Only the Markdown around them changes.
- A yes/no you can act on.
changedtells you whether the document needed formatting, which is all a check step has to know.
Copy-ready example
Section titled “Copy-ready example”curl https://api.markdownscribe.com/v1/md/format \ -H "X-API-Key: $MDSCRIBE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"markdown":"# Release notes\n\n* Faster builds\n* Smaller images\n\n__Bug fixes__ and *known issues* are listed below. \n\n| Area | Status |\n|---|---|\n| Builds | done |\n| Images | in progress |\n"}'TypeScript SDK
Section titled “TypeScript SDK”import { MarkdownScribeClient } from "@markdownscribe/sdk";
const client = new MarkdownScribeClient({ apiKey: process.env.MDSCRIBE_API_KEY! });const result = await client.format({ markdown: "# Release notes\n\n* Faster builds\n* Smaller images\n\n__Bug fixes__ and *known issues* are listed below. \n\n| Area | Status |\n|---|---|\n| Builds | done |\n| Images | in progress |\n",});Save the markdown value above as release-notes.md, then:
mdscribe format release-notes.md --writeWithout --write the formatted document goes to stdout; --check exits with code 8 when the file would change.
Response
Section titled “Response”Captured from the API on 2026-10-23.
{ "formatted": "# Release notes\n\n- Faster builds\n- Smaller images\n\n**Bug fixes** and _known issues_ are listed below.\n\n| Area | Status |\n| ------ | ----------- |\n| Builds | done |\n| Images | in progress |\n", "changed": true, "meta": { "request_id": "01M5MY6NVYFBPSZ0XTYD5F3NA5", "duration_ms": 90, "credits": 2 }}What changes: * and + list markers become -; __bold__ becomes **bold** and *italic* becomes _italic_; 1) becomes 1.; tables are aligned; *** and ___ become ---; ~~~ fences become backtick fences; trailing spaces go, except the two that mark a hard line break; line endings become \n. Setext headings (underlined with ===), list numbering and neighbouring lists with different markers are kept as written.
Credits, limits and errors
Section titled “Credits, limits and errors”2 credits per call. Each response says what it cost in the X-Credits-Charged header. Error responses are never charged.
- Option:
options.prose_wrapispreserve(the default),alwaysornever, and controls whether long paragraphs are re-wrapped. - Input:
markdown, up to 1,048,576 characters. Plain Markdown only: MDX is refused.
| Error | When |
|---|---|
unsupported_format |
The document is MDX (import/export lines, a JSX component or an MDX comment at the top level). line points at the first sign of it. Nothing is charged. |
validation |
markdown is missing, or prose_wrap is not one of the three values. |
payload_too_large |
The document is longer than 1,048,576 characters. |
unauthorized, insufficient_credits, rate_limited |
The key, the balance or the per-minute limit, as on every operation. |
Alternatives, and when MarkdownScribe is worth it
Section titled “Alternatives, and when MarkdownScribe is worth it”Checked on 2026-10-23 against the tool’s own documentation.
- Prettier.
npx prettier --write "**/*.md"formats Markdown in a terminal, andnpx prettier --check "**/*.md"exits non-zero when a file would change (prettier.io/docs/install). Use MarkdownScribe when your agent runs where there is no terminal (the Lovable or Base44 editor), or when you want format, lint, table of contents and frontmatter from one key with one error format and one bill.