format-json-cli
raw JSON → 1.1.0 verified Sat Apr 25 auth: no javascript
A CLI tool to format JSON files, designed as a post-hook to fix Prettier's JSON output. Version 1.1.0 is the latest stable release. It provides a simple command-line interface for formatting JSON files either globally or locally via npm scripts. Differentiators: lightweight, zero dependencies, focused solely on JSON formatting without opinionated defaults.
Common errors
error command not found: format-json-cli ↓
cause Package not installed globally or locally.
fix
Run
npm install -g format-json-cli or npx format-json-cli for one-off use. error Cannot find module '...' ↓
cause Using the package as a Node.js module dependency via require/import incorrectly.
fix
This is a CLI tool, not a library. Use the command line interface.
Warnings
gotcha The tool outputs formatted JSON to stdout by default; does NOT modify the file in-place without shell redirection. ↓
fix Use shell redirection: `format-json-cli input.json > output.json` or `mv` trick.
Install
npm install format-json-cli yarn add format-json-cli pnpm add format-json-cli Imports
- default
npx format-json-cli - CLI wrong
format-jsoncorrectformat-json-cli
Quickstart
npm install -g format-json-cli
echo '{"name":"test"}' > file.json
format-json-cli file.json # outputs formatted JSON to stdout
# To modify file in-place (requires redirection)
format-json-cli file.json > file.json.new && mv file.json.new file.json