# prettier-plugin-sort-json-natural

> Prettier plugin to sort JSON files alphanumerically by key

Latest version **0.0.7** (published 2022-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-plugin-sort-json-natural
pnpm add prettier-plugin-sort-json-natural
yarn add prettier-plugin-sort-json-natural
bun add prettier-plugin-sort-json-natural
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2022-04-26 |
| First published | 2022-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Robbe Claessens |
| Maintainers | robbecl |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-sort-json-natural
- Repository: https://github.com/RobbeCl/prettier-plugin-sort-json
- Homepage: https://github.com/RobbeCl/prettier-plugin-sort-json#readme
- Issues: https://github.com/RobbeCl/prettier-plugin-sort-json/issues
- npm.io page: https://npm.io/package/prettier-plugin-sort-json-natural

## Dependencies (1)

- [@types/prettier](https://npm.io/package/@types/prettier.md) ^2.2.0

## Recent versions

- 0.0.7 (latest) — 2022-04-26
- 0.0.6 — 2022-04-14
- 0.0.5 — 2022-04-14
- 0.0.4 — 2022-04-14

## README

# prettier-plugin-sort-json

A plugin for [Prettier](https://prettier.io) that sorts JSON files by property name.

## Requirements

This module requires an [LTS](https://github.com/nodejs/Release) Node version (v10.0.0+), and `prettier` v2.1.0+.

## Install

Using `npm`:

```console
npm install --save-dev prettier-plugin-sort-json-custom
```

Using `yarn`:

```console
yarn add --dev prettier-plugin-sort-json-custom
```

## Description

This plugin adds a JSON preprocessor that will sort JSON files containing a JSON object alphanumerically by key. JSON files containing Arrays or other non-Object values are skipped.

Object entries are sorted by key using [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort), according to each character's Unicode code point value.

## Examples

Before:

```json
{
    "z": null,
    "a": null,
    "b": null,
    "0": null,
    "exampleNestedObject": {
        "z": null,
        "a": null
    }
}
```

After:

```json
{
    "0": null,
    "a": null,
    "b": null,
    "exampleNestedObject": {
        "z": null,
        "a": null
    },
    "z": null
}
```

## Configuration

### JSON Recursive Sort

Sort JSON objects recursively, including all nested objects.

| Default | CLI Override            | API Override                |
| ------- | ----------------------- | --------------------------- |
| `false` | `--json-recursive-sort` | `jsonRecursiveSort: <bool>` |

# Remarks:

This code is official from https://github.com/Gudahtt/prettier-plugin-sort-json with a pull request from https://github.com/MasterEric/prettier-plugin-sort-json which was never approved. So I created this custom project which is published to npm to people can actually use it.

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