Skip to content

Format

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.

  • 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.

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.

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.

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.

  • 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. changed tells you whether the document needed formatting, which is all a check step has to know.
Terminal window
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"}'
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:

Terminal window
mdscribe format release-notes.md --write

Without --write the formatted document goes to stdout; --check exits with code 8 when the file would change.

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.

2 credits per call. Each response says what it cost in the X-Credits-Charged header. Error responses are never charged.

  • Option: options.prose_wrap is preserve (the default), always or never, 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, and npx 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.