Convert JSON or JavaScript objects into clean, human-readable plain text format.
npm install json-to-plain-text









---
json-to-plain-text is a lightweight npm package that converts JSON into a clean, human-readable plain-text.
Think of it as JSON.stringify(), but prettier, friendlier, and tailored for logs, debugging, and CLI output.
> [!NOTE]
> From version 2.0.0+, this package outputs plain text only.
> If you need colored output, please use version 1.1.4 .
---
- ๐น Convert JSON objects into easy-to-read plain text
- โก Tiny & fast (zero dependencies)
- ๐ Configurable separators, spacing, quotes, and array formatting
- โ
Great for logs, debugging, reports, and CLI tools
---
Use json-to-plain-text when you need:
- ๐ Readable logs โ no more squinting at raw JSON
- ๐ฅ CLI outputs โ format objects neatly for the terminal
- ๐งช Debugging helpers โ quickly inspect nested objects
- ๐ Reports/configs โ human-friendly data printing
---
``bash`
npm install json-to-plain-text
---
`js`
import { jsonToPlainText } from "json-to-plain-text";
---
`ts`
jsonToPlainText(data: unknown, options?: Options): string
- data (required) โ JSON-like input or JavaScript object.
- options (optional) โ Customize the formatting.
| Option | Type | Default | Description |
|---------------------------|---------|---------|-------------|
| separator | string | : | Character used between keys and values. |spacing
| | boolean | true | Align keys with spacing before colons. |squareBracketsForArray
| | boolean | false | Display arrays inside []. |doubleQuotesForKeys
| | boolean | false | Wrap object keys in double quotes. |doubleQuotesForValues
| | boolean | false | Wrap string values in double quotes. |
---
`ts
import { jsonToPlainText, Options } from "json-to-plain-text";
const data = {
place_id: "173937105",
osm_type: "way",
lat: "17.861533866867224",
lon: "78.8081441896764",
address: {
city: "Hyderabad",
state: "Telangana",
country: "India",
},
distance: 2,
};
const options: Options = {
separator: ":",
spacing: true,
squareBracketsForArray: false,
doubleQuotesForKeys: false,
doubleQuotesForValues: false,
};
console.log(jsonToPlainText(data, options));
`
`yaml``
place_id : 173937105
osm_type : way
lat : 17.861533866867224
lon : 78.8081441896764
address :
city : Hyderabad
state : Telangana
country : India
distance : 2
---
If this project helps you, consider supporting my open-source work:
A huge thanks to all sponsors for supporting my work!
---
This project is licensed under the MIT License.
---