JSON Handler
A lightweight VS Code extension that adds an editor title button for JSON / JSONC files to toggle between:
- Pretty formatted (multi-line, indented) JSON
- Single-line (collapsed) JSON – convenient for storing in single-line DB JSON columns or copying inline
Features
- Icon button appears in the editor title when a JSON / JSONC file is active
- Command palette access:
JSON: Toggle JSON Format
- Keybinding:
Ctrl+Alt+J (override or change in Keyboard Shortcuts)
- Safe: if the document content is not valid JSON, it will not modify it
- Remembers last state per document during the session
Usage
Open any .json or .jsonc file and click the Toggle JSON Format button in the top-right of the editor (title area), or run the command / shortcut.
Installation (Development)
npm install
npm run watch
# Press F5 in VS Code to launch Extension Development Host
Packaging
npm run package
Notes
- For JSONC (with comments / trailing commas), parsing will fail; enhancement could add a JSONC parser (e.g.
jsonc-parser ).
- Currently uses a simple in-memory map; persistent state could be added if desired.
Roadmap Ideas
- Support JSONC by stripping comments before parse
- Status bar indicator of current mode
- Auto-detect current mode instead of explicit state
- Multi-selection formatting
License
MIT
| |