Plugin icon

Markdown Formatter

formatting diff preview desktop formatting diff preview mobile

Description

Reformat/Normalize markdown with some configurable settings

Additional Information

Links:
Maintainers: bwat47
Version:1.6.12
Minimum app version:3.5
Downloads: This version:133
Last updated:2026-10-16T23:24:27Z

Markdown Formatter

A Joplin plugin that formats notes in the Markdown editor using configurable rules. It parses your note to find known structures and applies targeted edits, leaving unrecognized syntax untouched.

[!NOTE] This plugin is developed using AI

formatting example

Features

  • Safety-first formatting: Verifies document structure after each rule and skips any edit that would alter it unexpectedly.
  • Non-destructive edits: Diffs old and new text and replaces only changed spans in a single CodeMirror transaction, preserving cursor/scroll position and single-step undo.
  • Optional diff preview: Review character-level changes in a dialog before applying or canceling (off by default).

diff preview

Installation & Usage

Install Markdown Formatter from Joplin's Settings → Plugins, or install the .jpl archive from Releases.

With a note open in the Markdown editor, format it using any of the following:

  • Menu: Edit → Format Markdown
  • Shortcut: Ctrl+Alt+F (Windows/Linux) or Cmd+Alt+F (macOS)
  • Toolbar: Click the Format Markdown button

If the note is already formatted, nothing is written back.

Settings

Configure rules under Markdown Formatter in Joplin's plugin settings.

Headings

Setting Default Description
Normalize heading level increments On Lower skipped heading levels so headings increase one level at a time.
Minimum heading level None Floor for heading levels (H2 shifts all headings proportionally; first heading keeps the first heading and raises shallower ones; none disables).
Normalize heading marker spacing On Use one space between ATX heading markers and text, including optional closing markers.
Remove heading indentation On Move root-level ATX headings to column 0 without affecting indented code or nested headings.

Lists

Setting Default Description
Unordered list marker - Rewrite bullets to - or *, or preserve as written.
Normalize ordered list numbering On Renumber ordered lists sequentially while keeping the starting number.
List spacing Semantic Semantic preserves tight/loose rendering and fixes mixed spacing; also available as preserve, tight, or loose. Controls inner list-item block spacing.
List indentation Tabs Indent nested list markers with tabs, 2 spaces, or 4 spaces (widened when needed to preserve CommonMark nesting).

Inline Formatting & Links

Setting Default Description
Emphasis (italic) marker *emphasis* Prefer * or _ for emphasis delimiters.
Bold marker **bold** Prefer ** or __ for strong delimiters.
Double quote style Preserve Convert prose double quotes to straight or smart (curly) quotes.
Single quote style Preserve Convert prose single quotes and apostrophes to straight or smart (curly) quotes.
Link text spacing All Trim and collapse excess whitespace in link text (all also converts line breaks to spaces; spaces preserves line breaks; preserve leaves unchanged).

Blocks, Tables & Whitespace

Setting Default Description
Horizontal rule marker * * * Preferred syntax for horizontal rules.
Table style Preserve Compact pads cells with one space; aligned aligns pipes; preserve leaves tables unchanged.
Set default language on unlabeled code blocks Off Add the configured default language to unlabeled fenced code blocks (ignores indented code blocks).
Default code block language txt Language identifier used when the rule above is enabled.
Normalize blockquote marker spacing On Use one space after > markers and between nested markers (>> → > >). Skips quotes containing content that cannot be safely rewritten.
Ensure blank lines around blocks On Individual toggles to add one blank line before and after root-level headings, paragraphs, code blocks, math blocks, tables, blockquotes, and lists when neighboring content exists.
Ensure blank line after front matter On Add one blank line between YAML front matter and following content.
Collapse consecutive blank lines On Reduce multiple blank lines to one outside protected content.
Trim trailing whitespace On Remove trailing spaces/tabs outside protected content while preserving two-space hard line breaks.
Remove leading blank lines On Remove blank lines before the note's first content or front matter.
Ensure trailing newline On End the note with exactly one newline.

UI & Feedback

Setting Default Description
Preview changes before applying Off Show a diff dialog with Apply/Cancel buttons before modifying the note.
Display toast messages On Show a toast with added/removed character counts after formatting.

Safety Model

Each rule runs as an isolated pass against a parsed tree of the current Markdown:

  1. Locate structures the rule understands.
  2. Apply targeted string edits to the original source text.
  3. Re-parse the result and verify that the document structure still matches.
  4. Pass the verified tree to the next rule.

If a rule unexpectedly alters the document structure, it is skipped and formatting continues from the last safe state. If formatting fails entirely, the note is left unchanged. Protected regions—fenced/indented code blocks, inline code, YAML front matter, math, and HTML blocks—are preserved by whitespace and quote rules.

[!NOTE] If the diff preview reports Skipped by the structural safety check, please open an issue with a minimal Markdown example that reproduces it.

Known Limitations

  • Blockquotes: Quote interiors are not rewritten for block spacing; tables inside blockquotes are not reformatted; lists inside blockquotes are not reindented or respaced (though markers and numbering can still be normalized); multi-line links inside blockquotes are skipped by link text spacing.
  • Footnotes: Lists inside footnote definitions are not reindented.
  • Emphasis (_): Skips conversions where CommonMark would reinterpret intraword underscores or merge adjacent delimiter runs.
  • Smart quotes: Opening vs. closing direction is inferred from surrounding characters and may misguess unusual constructs. Code, math, HTML, front matter, backslash-escaped quotes, image alt text, and link titles are left untouched.
  • Link text spacing: Inline code inside link text and image alt text are never modified.
  • Performance: Formatting very large notes may be slow.

Development

Requires Node.js 22+.

# Install dependencies
npm install

# Run tests
npm test

# Lint (Oxlint + fallow) and check formatting (Oxfmt)
npm run lint
npm run format:check

# Build the plugin archive (outputs publish/com.bwat47.joplin-markdown-formatter.jpl)
npm run dist

License

MIT