| Name | format-json JSON |
| Version |
0.1.2
JSON |
| download |
| home_page | None |
| Summary | A CLI and pre-commit hook for formatting JSON with configurable trailing newline handling. |
| upload_time | 2025-10-18 06:49:43 |
| maintainer | None |
| docs_url | None |
| author | format-json maintainers |
| requires_python | >=3.10 |
| license | MIT License
Copyright (c) 2025 jsh9
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
----
The majority of this project's data files and code files are copied/adopted
from https://github.com/pre-commit/pre-commit-hooks. Below is the original
license of pre-commit-hooks.
----
Copyright (c) 2014 pre-commit dev team: Anthony Sottile, Ken Struys
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. |
| keywords |
cli
formatter
json
pre-commit
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# format-json
`format-json` is a JSON formatter that ships both a standalone CLI and a
pre-commit hook. It is adapted from the
[`pretty-format-json`](https://github.com/pre-commit/pre-commit-hooks)
pre-commit hook, with only one difference, as seen below.
**Table of Contents:**
<!--TOC-->
- [1. `format-json` vs `pretty-format-json`](#1-format-json-vs-pretty-format-json)
- [2. Usage](#2-usage)
- [2.1. As a command-line tool](#21-as-a-command-line-tool)
- [2.2. As a pre-commit hook](#22-as-a-pre-commit-hook)
- [2.3. Configuration options](#23-configuration-options)
- [3. Instructions for Maintainers](#3-instructions-for-maintainers)
<!--TOC-->
## 1. `format-json` vs `pretty-format-json`
| Feature | format-json | pretty-format-json |
| ---------------------------------- | :---------: | --------------------------------------------------------------------------------------- |
| Config option for trailing newline | ✅ | ❌ ([Won't implement ever](https://github.com/pre-commit/pre-commit-hooks/issues/1203)) |
| Preserves all digits of floats | ✅ | ❌ ([Unresolved since 2022](https://github.com/pre-commit/pre-commit-hooks/issues/780)) |
## 2. Usage
### 2.1. As a command-line tool
First, install it:
```bash
pip install format-json
```
Then, in the terminal, you can do something like:
```bash
format-json --autofix --no-eof-newline path/to/file.json
```
All command-line options from `pretty-format-json` are preserved, with the new
`--no-eof-newline` flag layered on top. See
[Section 2.3](#23-configuration-options) for the complete set of config
options.
### 2.2. As a pre-commit hook
Add the hook to your `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/jsh9/format-json
rev: <LATEST_VERSION>
hooks:
- id: format-json
args: [--autofix, --no-eof-newline]
```
(You can choose your own args.)
### 2.3. Configuration options
`format-json` accepts the same options whether invoked via the CLI or
pre-commit. Combine them as needed for your workflow:
- `--autofix` - automatically format json files
- `--indent ...` - Control the indentation (either a number for a number of
spaces or a string of whitespace). Defaults to 2 spaces.
- `--no-ensure-ascii` preserve unicode characters instead of converting to
escape sequences
- `--no-sort-keys` - when autofixing, retain the original key ordering (instead
of sorting the keys)
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
- `--no-eof-newline`: omit the trailing newline (format-json only).
## 3. Instructions for Maintainers
- Run `pip install -e .` to install this project in the "editable" mode.
- Run `pip install -r requirements.dev` to install developer dependencies.
- Run `pytest` to execute the automated tests replicated from the upstream
project.
- Use `tox` to exercise the full test matrix, linting, and formatting targets.
Raw data
{
"_id": null,
"home_page": null,
"name": "format-json",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "cli, formatter, json, pre-commit",
"author": "format-json maintainers",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/be/cc/b7c951eddf2d3ad491cc8fc10c3bc8d010bd28b3cb74aab7206637d45f10/format_json-0.1.2.tar.gz",
"platform": null,
"description": "# format-json\n\n`format-json` is a JSON formatter that ships both a standalone CLI and a\npre-commit hook. It is adapted from the\n[`pretty-format-json`](https://github.com/pre-commit/pre-commit-hooks)\npre-commit hook, with only one difference, as seen below.\n\n**Table of Contents:**\n\n<!--TOC-->\n\n- [1. `format-json` vs `pretty-format-json`](#1-format-json-vs-pretty-format-json)\n- [2. Usage](#2-usage)\n - [2.1. As a command-line tool](#21-as-a-command-line-tool)\n - [2.2. As a pre-commit hook](#22-as-a-pre-commit-hook)\n - [2.3. Configuration options](#23-configuration-options)\n- [3. Instructions for Maintainers](#3-instructions-for-maintainers)\n\n<!--TOC-->\n\n## 1. `format-json` vs `pretty-format-json`\n\n| Feature | format-json | pretty-format-json |\n| ---------------------------------- | :---------: | --------------------------------------------------------------------------------------- |\n| Config option for trailing newline | \u2705 | \u274c ([Won't implement ever](https://github.com/pre-commit/pre-commit-hooks/issues/1203)) |\n| Preserves all digits of floats | \u2705 | \u274c ([Unresolved since 2022](https://github.com/pre-commit/pre-commit-hooks/issues/780)) |\n\n## 2. Usage\n\n### 2.1. As a command-line tool\n\nFirst, install it:\n\n```bash\npip install format-json\n```\n\nThen, in the terminal, you can do something like:\n\n```bash\nformat-json --autofix --no-eof-newline path/to/file.json\n```\n\nAll command-line options from `pretty-format-json` are preserved, with the new\n`--no-eof-newline` flag layered on top. See\n[Section 2.3](#23-configuration-options) for the complete set of config\noptions.\n\n### 2.2. As a pre-commit hook\n\nAdd the hook to your `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/jsh9/format-json\n rev: <LATEST_VERSION>\n hooks:\n - id: format-json\n args: [--autofix, --no-eof-newline]\n```\n\n(You can choose your own args.)\n\n### 2.3. Configuration options\n\n`format-json` accepts the same options whether invoked via the CLI or\npre-commit. Combine them as needed for your workflow:\n\n- `--autofix` - automatically format json files\n- `--indent ...` - Control the indentation (either a number for a number of\n spaces or a string of whitespace). Defaults to 2 spaces.\n- `--no-ensure-ascii` preserve unicode characters instead of converting to\n escape sequences\n- `--no-sort-keys` - when autofixing, retain the original key ordering (instead\n of sorting the keys)\n- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.\n- `--no-eof-newline`: omit the trailing newline (format-json only).\n\n## 3. Instructions for Maintainers\n\n- Run `pip install -e .` to install this project in the \"editable\" mode.\n- Run `pip install -r requirements.dev` to install developer dependencies.\n- Run `pytest` to execute the automated tests replicated from the upstream\n project.\n- Use `tox` to exercise the full test matrix, linting, and formatting targets.\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 jsh9\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \n ----\n \n The majority of this project's data files and code files are copied/adopted\n from https://github.com/pre-commit/pre-commit-hooks. Below is the original\n license of pre-commit-hooks.\n \n ----\n \n Copyright (c) 2014 pre-commit dev team: Anthony Sottile, Ken Struys\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.",
"summary": "A CLI and pre-commit hook for formatting JSON with configurable trailing newline handling.",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/jsh9/format-json",
"Issues": "https://github.com/jsh9/format-json/issues",
"Repository": "https://github.com/jsh9/format-json"
},
"split_keywords": [
"cli",
" formatter",
" json",
" pre-commit"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0ccafe397032531f633bc998f841ab6ca2d87a009b93a1ff8338ba3c0054be4f",
"md5": "cf8a0e463c2e6537adaaf9fb5e1b2a04",
"sha256": "aaa9971bde0e9d9131cdbdc073017526d7f5a87b2131b42cd408850b68e15a75"
},
"downloads": -1,
"filename": "format_json-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cf8a0e463c2e6537adaaf9fb5e1b2a04",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7242,
"upload_time": "2025-10-18T06:49:42",
"upload_time_iso_8601": "2025-10-18T06:49:42.223537Z",
"url": "https://files.pythonhosted.org/packages/0c/ca/fe397032531f633bc998f841ab6ca2d87a009b93a1ff8338ba3c0054be4f/format_json-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "beccb7c951eddf2d3ad491cc8fc10c3bc8d010bd28b3cb74aab7206637d45f10",
"md5": "eb48473d324b31490fafd2509f93013a",
"sha256": "65de970bf8ea55886cdcb5cbb95c308823365e408db6597439543f97e08d4251"
},
"downloads": -1,
"filename": "format_json-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "eb48473d324b31490fafd2509f93013a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11410,
"upload_time": "2025-10-18T06:49:43",
"upload_time_iso_8601": "2025-10-18T06:49:43.199497Z",
"url": "https://files.pythonhosted.org/packages/be/cc/b7c951eddf2d3ad491cc8fc10c3bc8d010bd28b3cb74aab7206637d45f10/format_json-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-18 06:49:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jsh9",
"github_project": "format-json",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "format-json"
}