How to Format JSON in VS Code, Notepad++, Sublime, IntelliJ and Vim
· 5 min read
In VS Code, open the JSON file and press Shift+Alt+F on Windows, Shift+Option+F on macOS or Ctrl+Shift+I on Linux to run Format Document. Notepad++ and Sublime Text need a free plugin (JSTool or JSON Viewer, and Pretty JSON), IntelliJ uses Reformat Code (Ctrl+Alt+L), and Vim can pipe the buffer through jq.
If you are not in an editor at all, paste the text into the JSON formatter instead; it indents and validates in your browser without uploading. The sections below give the exact steps per editor, and the last part covers why formatting sometimes silently does nothing. For formatting from code (JSON.stringify, json.dumps, Go), see pretty-printing JSON in JavaScript, Python, Go and the CLI.
Shortcut table
| Editor | Needs a plugin? | Windows / Linux | macOS |
|---|---|---|---|
| VS Code | No | Shift+Alt+F (Linux: Ctrl+Shift+I) | Shift+Option+F |
| Notepad++ (JSTool) | Yes, JSTool | Ctrl+Alt+M (JSFormat) | Windows only |
| Notepad++ (JSON Viewer) | Yes, JSON Viewer | Ctrl+Alt+Shift+M (Format JSON) | Windows only |
| Sublime Text | Yes, Pretty JSON | Ctrl+Alt+J | Cmd+Ctrl+J |
| IntelliJ IDEA, WebStorm, PyCharm | No | Ctrl+Alt+L | Cmd+Option+L |
| Vim / Neovim | No (needs jq or Python installed) | :%!jq . | :%!jq . |
VS Code
VS Code ships a JSON language service, so no extension is required.
- Open the file. Check the language mode in the bottom-right status bar says JSON (or JSON with Comments). If it says Plain Text, click it and choose JSON; this is the usual reason formatting does nothing for pasted text in an untitled tab.
- Press the shortcut above, or open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) and run Format Document. - To format only part of a file, select it and run Format Selection (
Ctrl+K Ctrl+F/Cmd+K Cmd+F).
To format automatically on every save and control indentation, add this to your user or workspace settings.json:
{
"[json]": {
"editor.formatOnSave": true,
"editor.tabSize": 2
}
}If you have Prettier installed and Format Document asks which formatter to use, pick one with Format Document With... > Configure Default Formatter. Both produce valid JSON; Prettier respects your .prettierrc settings.
Notepad++
Notepad++ has no built-in JSON formatter. Install one of two free plugins through Plugins > Plugins Admin: search the Available tab, tick the plugin, click Install and let Notepad++ restart.
- JSTool: open the file and choose Plugins > JSTool > JSFormat, or press
Ctrl+Alt+M. JSMin in the same menu minifies it back. - JSON Viewer: choose Plugins > JSON Viewer > Format JSON (
Ctrl+Alt+Shift+M). Show JSON Viewer (Ctrl+Alt+Shift+J) opens a side panel tree you can click through, which helps with deeply nested data.
Plugin shortcuts can change between versions or clash with other plugins. If a key does nothing, open Settings > Shortcut Mapper > Plugin commands to see or reassign the binding. Both plugins stop with an error on invalid JSON, so a failed format is often a syntax problem rather than a plugin problem.
Sublime Text
- Install Package Control if you have not already: Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) > Install Package Control. - Command Palette > Package Control: Install Package > Pretty JSON.
- Open the JSON and run Pretty JSON: Format JSON from the Command Palette, or press
Ctrl+Alt+J(Cmd+Ctrl+Jon macOS).
Pretty JSON also offers Minify (compress) JSON, Validate and a jq query command if jq is on your PATH. Indentation and key sorting are set in Preferences > Package Settings > Pretty JSON > Settings.
IntelliJ IDEA, WebStorm, PyCharm and other JetBrains IDEs
Open the file and choose Code > Reformat Code, or press Ctrl+Alt+L (Cmd+Option+L on macOS). With a selection, only the selection is reformatted. Ctrl+Alt+Shift+L (Cmd+Option+Shift+L) opens a dialog for options such as optimizing the whole file or only changed lines.
Indent size and spacing live in Settings > Editor > Code Style > JSON. For a scratch buffer, create a scratch file (Ctrl+Alt+Shift+Insert on Windows/Linux, Cmd+Shift+N on macOS), choose JSON as the type, paste and reformat. If the file is huge, JetBrains IDEs may disable code insight and formatting for performance.
Vim and Neovim
Vim has no JSON formatter of its own, but it can filter the buffer through any command-line program. With jq installed:
" whole buffer
:%!jq .
" with 4-space indent
:%!jq --indent 4 .
" without jq, using Python
:%!python3 -m json.tool
" visual selection only: select, then
:'<,'>!jq .If the JSON is invalid, jq prints an error and Vim replaces the buffer with that message; press u to undo. To make gq format JSON files, add autocmd FileType json setlocal formatprg=jq\ . to your vimrc. Neovim users with an LSP setup can run vim.lsp.buf.format() through a JSON language server instead. The jq cheat sheet covers the filters you can run the same way to sort or extract data.
When the format command does nothing
- The JSON is invalid. Every formatter refuses to indent text it cannot parse. A trailing comma, single quotes or an unescaped quote is the usual cause. Paste it into the JSON syntax checker to get the exact line, or see common JSON errors and fixes.
- It is JSONC or JSON5. Files like
tsconfig.jsonallow comments and trailing commas. VS Code formats them as JSON with Comments; strict plugins may fail. Our JSON vs JSON5 vs JSONC comparison explains the differences. - Wrong language mode. The editor treats the buffer as plain text. Set the mode to JSON.
- The file is very large. Editors may skip formatting on files of tens of megabytes. Use
jq . big.json > pretty.jsonon the command line or the large JSON viewer. - It came from an LLM. Model output often has prose around it, smart quotes or truncation. The LLM JSON repair tool cleans those up before you format.
FAQ
What is the shortcut to format JSON in VS Code?
Shift+Alt+F on Windows, Shift+Option+F on macOS and Ctrl+Shift+I on Linux. You can also run Format Document from the Command Palette. The file's language mode must be JSON.
How do I format JSON in Notepad++?
Install the JSTool plugin via Plugins > Plugins Admin, then use Plugins > JSTool > JSFormat (Ctrl+Alt+M). Alternatively install JSON Viewer and use Plugins > JSON Viewer > Format JSON.
Can Windows Notepad format JSON?
No. Notepad has no formatting feature. Use Notepad++ with a plugin, VS Code, or paste the text into a browser-based formatter.
How do I format JSON in IntelliJ?
Open the file and press Ctrl+Alt+L (Cmd+Option+L on macOS), or choose Code > Reformat Code. Indentation is configured under Settings > Editor > Code Style > JSON.
Why won't my editor format my JSON?
Usually because the text is not valid JSON (trailing comma, single quotes, comments) or the editor is in plain-text mode. Validate the JSON first, then set the language mode to JSON.

