# stringify-json-object

> Stringify and format a JSON object

Latest version **3.0.0** (published 2023-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install stringify-json-object
pnpm add stringify-json-object
yarn add stringify-json-object
bun add stringify-json-object
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-01-24 |
| First published | 2020-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Connor White |
| Maintainers | bconnorwhite |
| Keywords | json, stringify, format, pretty, typed, object, typescript, ts |

## Links

- npm: https://www.npmjs.com/package/stringify-json-object
- Repository: https://github.com/bconnorwhite/stringify-json-object
- Homepage: https://connorwhite.dev/github/stringify-json-object
- Issues: https://github.com/bconnorwhite/stringify-json-object/issues
- npm.io page: https://npm.io/package/stringify-json-object

## Dependencies (1)

- [types-json](https://npm.io/package/types-json.md) ^3.1.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.0 (latest) — 2023-01-24
- 2.0.0 — 2023-01-18
- 1.0.7 — 2020-12-15
- 1.0.6 — 2020-10-04
- 1.0.5 — 2020-09-13
- 1.0.4 — 2020-09-03
- 1.0.3 — 2020-09-02
- 1.0.2 — 2020-08-29
- 1.0.1 — 2020-08-28
- 1.0.0 — 2020-08-28

## README

<!--BEGIN HEADER-->
<div id="top" align="center">
  <h1>stringify-json-object</h1>
  <a href="https://npmjs.com/package/stringify-json-object">
    <img alt="NPM" src="https://img.shields.io/npm/v/stringify-json-object.svg">
  </a>
  <a href="https://github.com/bconnorwhite/stringify-json-object">
    <img alt="TypeScript" src="https://img.shields.io/github/languages/top/bconnorwhite/stringify-json-object.svg">
  </a>
  <a href="https://coveralls.io/github/bconnorwhite/stringify-json-object?branch=master">
    <img alt="Coverage Status" src="https://img.shields.io/coveralls/github/bconnorwhite/stringify-json-object.svg?branch=master">
  </a>
</div>

<br />

<blockquote align="center">Stringify and format a JSON object.</blockquote>

<br />

_If I should maintain this repo, please ⭐️_
<a href="https://github.com/bconnorwhite/stringify-json-object">
  <img align="right" alt="GitHub stars" src="https://img.shields.io/github/stars/bconnorwhite/stringify-json-object?label=%E2%AD%90%EF%B8%8F&style=social">
</a>

_DM me on [Twitter](https://twitter.com/bconnorwhite) if you have questions or suggestions._
<a href="https://twitter.com/bconnorwhite">
  <img align="right" alt="Twitter" src="https://img.shields.io/twitter/url?label=%40bconnorwhite&style=social&url=https%3A%2F%2Ftwitter.com%2Fbconnorwhite">
</a>

---
<!--END HEADER-->

## Installation

```sh
yarn add stringify-json-object
```

```sh
npm install stringify-json-object
```

```sh
pnpm add stringify-json-object
```

## Usage

The `stringify` function works like `JSON.stringify`:

```ts
import stringify from "stringify-json-object";

stringify(true); // 'true'
stringify(1); // '1'
stringify("foo"); // '"foo"'
stringify({ foo: "bar" }); // '{"foo":"bar"}'
stringify({ foo: "bar", missing: undefined }); // '{"foo":"bar"}'

```

The `stringify` function also accepts an options argument, to easily format the output:

```ts
import stringify from "stringify-json-object";

stringify({ foo: "bar" }, { pretty: true }); // '{\n  "foo": "bar"\n}"
```

Additionally, primitives resolve to typed string literals:
```ts
import stringify from "stringify-json-object";

stringify(true); // "true"
stringify(1); // "1"
stringify("foo"); // "\"foo\""
stringify({ foo: "bar" }); // string

```

<!--BEGIN FOOTER-->

<br />

<h2 id="dependencies">Dependencies<a href="https://www.npmjs.com/package/stringify-json-object?activeTab=dependencies"><img align="right" alt="dependencies" src="https://img.shields.io/librariesio/release/npm/stringify-json-object.svg"></a></h2>

- [types-json](https://www.npmjs.com/package/types-json): Type checking for JSON values

<br />

<h3>Dev Dependencies</h3>

- [autorepo](https://www.npmjs.com/package/autorepo): Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

<br />

<h2 id="license">License <a href="https://opensource.org/licenses/MIT"><img align="right" alt="license" src="https://img.shields.io/npm/l/stringify-json-object.svg"></a></h2>

[MIT](https://opensource.org/licenses/MIT)
<!--END FOOTER-->

<br />

## Related Packages

- [parse-json-object](https://www.npmjs.com/package/parse-json-object): Parse a typed JSON object

---
_Source: https://npm.io/package/stringify-json-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
