Best LLMs for Markdown Newline Repair
Re-inserts blank lines into a markdown document whose line breaks were stripped (headings, separators, and paragraphs collapsed onto one line). Must not modify any non-whitespace character — pure whitespace restoration.
Models
Frontier on this task: Gemini 3.5 Flash at 9.33 / 10. Quality bar at 90%: 8.40.
point-estimate floor (CI low) · upper CI (less certain) · Bars sorted by blended cost; best-value model first. Greyed rows are MEDIUM+ models whose point estimate clears the bar but whose CI low does not.
| Model | Quality score | CI low | Cost / 1k runs | vs best value |
|---|---|---|---|---|
| MiniMax M3 | 8.52 / 10 | 8.10 | $5.11 | best value |
| Gemini 3.5 Flash | 9.33 / 10 | 9.20 | $165.89 | 32x more expensive |
| Qwen 3.6 Plus | 1.87 / 10 | 1.57 | $46.93 | 9.2x more expensive |
| Kimi K2.6 | 1.77 / 10 | 1.33 | $55.74 | 11x more expensive |
| Qwen 3.5 Flash | 1.96 / 10 | 1.74 | $8.50 | 1.7x more expensive |
| Qwen 3.7 Plus | 5.87 / 10 | 5.67 | $19.64 | 3.8x more expensive |
| Qwen 3.6 Flash | 5.12 / 10 | 4.86 | $32.10 | 6.3x more expensive |
| Grok 4.5 | 6.67 / 10 | 6.41 | $66.15 | 13x more expensive |
Cost breakdown
| Model | Quality | Confidence | Cost / 1k runs | Overpay | Mode |
|---|---|---|---|---|---|
| MiniMax M3 ★ MiniMax | 8.52 / 10 CI [8.10, 8.94] | MEDIUM | $5.11 | best value | batch |
| Gemini 3.5 Flash best Gemini | 9.33 / 10 CI [9.20, 9.47] | RANKED | $165.89 | 32x | batch |
Overpay shows how much more you pay than the best-value model that clears the quality bar (marked ★) — the best-value good-enough option. "16x" means you overpay 16× — 16× that reference for no quality benefit above the bar. Typical call shape for this task: 4235 input tokens → 9474 output tokens, EMA-tracked from production traffic. Cost is the observed, all-in $ per 1,000 task runs: each model's own measured usage on this task — output verbosity, thinking/reasoning tokens, cache reads and writes, and the spend on its billed failures — priced at current list rates and adjusted by the billing overhead we actually reconcile against provider invoices. Models that answer tersely cost what they actually cost; models that think at length pay for it. Not comparable to providers' advertised $/1M list rates — this is what running the task costs, not a per-token price.
Prompt templates
The system + user template pair used for this task.
MARKDOWN_NEWLINE_REPAIR_SYSTEM_PROMPT +
MARKDOWN_NEWLINE_REPAIR_USER_PROMPT
(1591 calls in window)
System prompt
You receive a markdown document whose line breaks were stripped, so headings, separators, and paragraphs run together on one line.
Your job is to re-insert blank lines so the markdown renders correctly. You must NOT modify any non-whitespace character.
Required reformatting:
- Put each heading marker (`##`, `###`, `####`) on its own line, with a blank line before AND after.
- Put each `---` separator on its own line, with a blank line before AND after.
- For headings whose text was concatenated with following body text (e.g., `### The Strategic Context The present conflict in the Persian Gulf has entered...`): keep ONLY the actual heading title on the heading line, and start a new paragraph for the body. Heading titles are typically 2-12 words, do not contain sentence-ending punctuation, and end at the boundary where running prose begins.
- Insert paragraph breaks (blank lines) between distinct paragraphs in body prose. A paragraph break belongs where a topic shifts or where the original author would have started a new paragraph. Sentences that elaborate the same point stay together.
- Preserve existing italic/bold markers like `*Author:*`, `**bold**`, `*emphasis*`. If the metadata line at the top concatenates `*Author:* X *Subject:* Y *Topic:* Z`, put each on its own line.
- Preserve list markers (`- `, `* `, `1. `). If a list runs inline, put each list item on its own line.
Hard constraints:
- Do NOT add, remove, or change any letter, digit, punctuation, citation marker (`[^21]`, `[^21][^43]`), URL, or other non-whitespace character.
- Do NOT rephrase, summarize, expand, or "fix" any wording.
- Do NOT insert headings, lists, or markers that were not already there.
- Do NOT remove headings, separators, or markers that were there.
- Output the entire input verbatim except for whitespace insertions.
If you cannot satisfy the no-content-change rule for any reason, return the input unchanged rather than producing a modified version.
## Required Output Format
Your response MUST be a single, valid JSON object conforming to this schema:
```json
{schema_json_string}
```User prompt
Reflow this markdown by inserting blank lines and paragraph breaks. Do not change any non-whitespace character.
Markdown text:
{markdown_text}
Return the reflowed markdown matching this schema:
The required JSON output schema is provided in the system prompt.