Socket
Book a DemoInstallSign in
Socket

json-to-plain-text

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-to-plain-text

Convert JSON or JavaScript objects into clean, human-readable plain text format.

1.2.0
latest
Source
npmnpm
Version published
Weekly downloads
8.2K
14.24%
Maintainers
1
Weekly downloads
ย 
Created
Source

json-to-plain-text

Version Stars Downloads License Maintenance Issues GitHub Sponsors Install size Bundle size Known Vulnerabilities

๐Ÿ“– Overview

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 .

โœจ Features

  • ๐Ÿ”น 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

๐Ÿ” Why use this?

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

๐Ÿš€ Installation

npm install json-to-plain-text

๐Ÿ“ฆ Usage

import { jsonToPlainText } from "json-to-plain-text";

โš™๏ธ API

jsonToPlainText(data: unknown, options?: Options): string

Parameters

  • data (required) โ€“ JSON-like input or JavaScript object.
  • options (optional) โ€“ Customize the formatting.
OptionTypeDefaultDescription
separatorstring:Character used between keys and values.
spacingbooleantrueAlign keys with spacing before colons.
squareBracketsForArraybooleanfalseDisplay arrays inside [].
doubleQuotesForKeysbooleanfalseWrap object keys in double quotes.
doubleQuotesForValuesbooleanfalseWrap string values in double quotes.

๐Ÿ’ก Example

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));

โœ… Output

place_id : 173937105
osm_type : way
lat      : 17.861533866867224
lon      : 78.8081441896764
address  : 
city     : Hyderabad
state    : Telangana
country  : India
distance : 2

๐Ÿ’ Support

If this project helps you, consider supporting my open-source work:

A huge thanks to all sponsors for supporting my work!

๐Ÿ“œ License

This project is licensed under the MIT License.

๐Ÿ‘จโ€๐Ÿ’ป Author

Keywords

json

FAQs

Package last updated on 26 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.