Skip to content

How to format JSON in Notepad++

Short answer

To format JSON in Notepad++, install the JSON Viewer plugin from Plugins > Plugins Admin, then press Ctrl+Alt+Shift+M (Plugins > JSON Viewer > Format JSON). Notepad++ has no built-in JSON formatter.

Updated · 3 min read

Install JSON Viewer

  1. Open Plugins > Plugins Admin….
  2. On the Available tab, type JSON Viewer in the Search box.
  3. Tick the checkbox next to JSON Viewer and click Install.
  4. Confirm the prompt. Notepad++ restarts with the plugin installed.

If Install stays grey, tick the checkbox instead of selecting the name. On a permission error, run Notepad++ as administrator once: plugins go into the program folder.

Format JSON in Notepad++: commands and shortcuts

Command Menu path Shortcut
Format Plugins > JSON Viewer > Format JSON Ctrl + Alt + Shift + M
Minify Plugins > JSON Viewer > Compress JSON Ctrl + Alt + Shift + C
Sort keys Plugins > JSON Viewer > Sort by key (ascending) Ctrl + Alt + Shift + K
Tree panel Plugins > JSON Viewer > Show JSON Viewer Ctrl + Alt + Shift + J
JSON Lines Plugins > JSON Viewer > Format JSON Lines none

With nothing selected, each command works on the whole file. Select a block to format only that, such as one JSON object inside a log. Format JSON Lines formats each line of a .jsonl file as its own document. In the tree panel, right-click a node for Copy Node Name, Copy Node Value or Copy Node Path.

Settings

Plugins > JSON Viewer > Settings controls the output:

  • Indentation: Auto detect, the default, follows the document’s Notepad++ tab settings. For two spaces, pick Use space and set Count to 2.
  • Line Ending: auto detect, Windows (CR LF) or Unix (LF).
  • Format arrays on a single line keeps [1, 2, 3] on one line.
  • Ignore comments in json and Ignore trailing comma are on by default, so such files still parse.
  • Auto format json file when opened.

When the plugin says the JSON is invalid

A JSON Viewer: Error box says An error occurred while parsing the JSON. Check the current selection for the potential issue. The plugin selects the text from the failure point onward, so look at the first highlighted character. The usual culprits are a missing comma, single quotes, Python’s True or None, and an unescaped double quote inside a string. The JSON validator names the line, column and likely fix.

JSTool and JSON Tools

  • JSTool: Plugins > JSTool > JSFormat, Ctrl + Alt + M. It is a JavaScript formatter, so it re-indents invalid JSON without a warning; validate first. Its tree viewer is on Ctrl + Alt + J.
  • JSON Tools (menu name JsonTools): Plugins > JsonTools > Pretty-print current JSON file, Ctrl + Alt + Shift + P. It adds linting, a queryable tree and JSON Schema validation.

JSON Tools also uses Ctrl + Alt + Shift + C and Ctrl + Alt + Shift + J, the same keys as JSON Viewer. With both installed, reassign one in Settings > Shortcut Mapper… on the Plugin commands tab.

Without a plugin

Language > J > JSON adds colors and folding but will not re-indent a one-line file. Where you cannot install plugins, there are two options.

Format in the browser. Paste the JSON into the JSON formatter, press Format and copy the result back. It runs in your browser, so nothing is uploaded.

Run Python from the Run menu. Save the file, press F5 (Run > Run…) and enter:

cmd /c python -m json.tool "$(FULL_CURRENT_PATH)" | clip

The formatted JSON lands on the clipboard: press Ctrl + A, then Ctrl + V. $(FULL_CURRENT_PATH) reads the saved file, hence saving first. Save… in the Run dialog adds the command to the Run menu with a shortcut. Use py if Windows says Python was not found. Accented letters become \u00e9-style escapes, which is valid JSON.

More one-liners are in pretty print JSON on the command line. VS Code formats JSON without a plugin: see how to format JSON in VS Code. All guides are listed under JSON guides.

Questions

Why did my comments disappear after Format JSON?

JSON Viewer reads the file with Ignore comments in json on, so it skips the comments while parsing and has nothing to write back. Keep a copy if you need them. With the option off, the plugin reports an error instead.

Does JSON Viewer change numbers?

No. It reads numbers as text and writes them back unchanged, so 1.50 stays 1.50 and long IDs keep every digit.

Which Notepad++ versions does JSON Viewer support?

Version 2.2.0.0 is in Plugins Admin for 32-bit, 64-bit and ARM64 Notepad++ 8.4.5 and later. If it is missing from the Available tab, update Notepad++.

Tools for this

Esc