# strfy-js

> Stringify JSON as JavaScript with extended serialization capabilities

Latest version **3.2.3** (published 2026-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install strfy-js
pnpm add strfy-js
yarn add strfy-js
bun add strfy-js
```

## Health

**Score 65/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.2.3 |
| Published | 2026-07-31 |
| First published | 2024-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Constructive <developers@constructive.io> |
| Maintainers | pyramation |

## Links

- npm: https://www.npmjs.com/package/strfy-js
- Repository: https://github.com/constructive-io/dev-utils
- Issues: https://github.com/constructive-io/dev-utils/issues
- npm.io page: https://npm.io/package/strfy-js

## Dependencies (1)

- [minimatch](https://npm.io/package/minimatch.md) ^10.1.1

## Recent versions

- 3.2.3 (latest) — 2026-07-31
- 3.2.2 — 2026-05-09
- 3.2.1 — 2026-01-29
- 3.2.0 — 2026-01-20
- 3.1.10 — 2025-12-27
- 3.1.9 — 2025-12-27
- 3.1.8 — 2025-12-27
- 3.1.7 — 2025-12-17
- 3.1.6 — 2025-12-14
- 3.1.5 — 2025-11-28
- 3.1.4 — 2025-11-26
- 3.1.3 — 2025-11-24
- 3.1.2 — 2025-11-24
- 3.1.1 — 2025-11-23
- 3.1.0 — 2025-11-23
- … 11 more at https://npm.io/package/strfy-js/versions

## README

# strfy-js

<p align="center" width="100%">
  <img src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" height="250">
</p>

## Stringify JSON as JavaScript 🌴

<p align="center" width="100%">
  <a href="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml">
    <img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
  </a>
  <a href="https://github.com/constructive-io/dev-utils/blob/main/LICENSE">
    <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
  </a>
</p>

`strfy-js` is a custom JavaScript serialization library designed to extend the capabilities of JSON serialization. This library is particularly useful for generating JavaScript objects directly from JSON, enabling developers to work with JSON data more effectively within JavaScript environments.

## Features

- **🛠️ Extended Serialization**: Converts JSON to JavaScript objects, supporting output, such as properties without quotes, not typically handled by standard JSON. 

- **⚙️ Customizable**: Offers various options to customize the output, making it suitable for different use cases. Tailor the serialization process to meet your specific requirements.

- **⚡ Lightweight and Fast**: Optimized for performance, making it a practical choice for applications that require fast serialization of large amounts of data. Ideal for handling high-load environments efficiently.

## Installation

To install `strfy-js`, use npm or yarn:

```bash
npm install strfy-js
# or
yarn add strfy-js
``` 

## Usage

Import `jsStringify` from `strfy-js` and use it to serialize JavaScript objects:

```js
import { jsStringify } from 'strfy-js';

const obj = {
  "$schema": "schema.json",
  "chain_id": "cosmos-1",
  "logo_URIs": {
    "png": "cosmos.png"
  },
  "binaries": {
    "linux/amd64": "cosmos-bin.tar.gz"
  }
};

const options = {
    space: 2,
    camelCase: true,
    quotes: 'single'
};

console.log(jsStringify(obj, options));
// OUTPUT:
{
  $schema: 'schema.json',
  chainId: 'cosmos-1',
  logoURIs: {
    png: 'cosmos.png'
  },
  binaries: {
    "linux/amd64": 'cosmos-bin.tar.gz'
  }
}
```

## Options

`jsStringify` accepts the following options in the `StringifyOptions` interface:

- `space` (optional): Specifies the number of spaces to use for indentation, defaults to `0`.
- `replacer` (optional): A function that alters the behavior of the stringification process by filtering and transforming the values.
- `quotes` (optional): Determines the type of quotes around strings. Can be `'single'`, `'double'`, or determined automatically to avoid escapes.
- `inlineArrayLimit` (optional): Allows arrays to be serialized inline if they have fewer elements than the specified limit.
- `camelCase` (optional): When set to `true`, object keys are transformed into camelCase.
- `camelCaseFn` (optional): A custom function that can be provided to convert object keys into camelCase using a custom transformation logic.

---

## Development

### Setup

1. Clone the repository:

```bash
git clone https://github.com/constructive-io/dev-utils.git
```

2. Install dependencies:

```bash
cd dev-utils
pnpm install
pnpm build
```

3. Test the package of interest:

```bash
cd packages/<packagename>
pnpm test:watch
```

## Credits

**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**

## Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

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