Pretty-print JSON to the terminal with syntax highlighting and structure-aware formatting.
- Node.js v20 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @topcli/pretty-json
# or
$ yarn add @topcli/pretty-json
import prettyJSON from "@topcli/pretty-json";
prettyJSON({
foo: "bar",
hello: "world!",
arr: [1, 2, 3]
});
It will produce the following stdout:
Prints a JSON-compatible object or array to the terminal with syntax highlighting and structured indentation.
- Supports plain objects, arrays, and nested structures.
- Skips functions and symbols.
- Color-codes data types (strings, numbers, booleans, etc.).
- Outputs readable, formatted JSON — ideal for CLI inspection.
MIT