{"id":50806474,"url":"https://github.com/select/fjson-fmt","last_synced_at":"2026-06-13T01:34:11.641Z","repository":{"id":363186793,"uuid":"1262241664","full_name":"select/fjson-fmt","owner":"select","description":"Prettier-style check+write JSON formatter using the FracturedJson algorithm (Rust engine compiled to WASM), built to run alongside oxfmt.","archived":false,"fork":false,"pushed_at":"2026-06-07T20:41:03.000Z","size":1689,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-13T01:34:10.231Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://select.github.io/fjson-fmt/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/select.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-07T18:47:03.000Z","updated_at":"2026-06-07T20:41:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/select/fjson-fmt","commit_stats":null,"previous_names":["select/fjson-fmt"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/select/fjson-fmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/select%2Ffjson-fmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/select%2Ffjson-fmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/select%2Ffjson-fmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/select%2Ffjson-fmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/select","download_url":"https://codeload.github.com/select/fjson-fmt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/select%2Ffjson-fmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34269364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-13T01:34:11.073Z","updated_at":"2026-06-13T01:34:11.625Z","avatar_url":"https://github.com/select.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fjson-fmt\n\nA **Prettier-style `--check` + `--write` formatter for JSON** built on the\n[FracturedJson](https://j-brooke.github.io/FracturedJson/) algorithm - compact,\nhuman-readable JSON with smart line breaks and table-like alignment.\n\nThe formatting engine is the Rust crate\n[`fracturedjson`](https://github.com/fcoury/fracturedjson-rs) (MIT), **vendored\ninto `crate/` and compiled to WebAssembly** via `wasm-pack`. The CLI is a thin\nNode.js layer that adds the check/write workflow, globbing, and config discovery\nthat no existing FracturedJson port provides.\n\nIt turns this:\n\n```json\n{\n  \"Isotopes\": {\n    \"Hydrogen\": [1, 2, 3],\n    \"Carbon\": [11, 12, 13, 14],\n    \"Molybdenum\": [92, 94, 95, 96, 97, 98, 100]\n  },\n  \"ElementProperties\": [\n    { \"symbol\": \"C\", \"number\": 6, \"mass\": { \"amu\": 12, \"round\": 12 }, \"phase\": \"solid\" },\n    { \"symbol\": \"O\", \"number\": 8, \"mass\": { \"amu\": 16, \"round\": 16 } },\n    { \"symbol\": \"Fe\", \"number\": 26, \"mass\": { \"amu\": 56, \"round\": 56 }, \"phase\": \"solid\" }\n  ]\n}\n```\n\nusing `npx fjson-fmt --stdin \u003c example.json`, into this - compact, but with fields aligned like a table:\n\n```json\n{\n    \"Isotopes\"         : {\n        \"Hydrogen\"  : [ 1,  2,  3                 ],\n        \"Carbon\"    : [11, 12, 13, 14             ],\n        \"Molybdenum\": [92, 94, 95, 96, 97, 98, 100]\n    },\n    \"ElementProperties\": [\n        { \"symbol\": \"C\",  \"number\":  6, \"mass\": {\"amu\": 12, \"round\": 12}, \"phase\": \"solid\" },\n        { \"symbol\": \"O\",  \"number\":  8, \"mass\": {\"amu\": 16, \"round\": 16}                   },\n        { \"symbol\": \"Fe\", \"number\": 26, \"mass\": {\"amu\": 56, \"round\": 56}, \"phase\": \"solid\" }\n    ]\n}\n```\n\nLong arrays of arrays get packed multiple items per line, neatly aligned:\n\n```json\n{\n    \"Bonds\": [\n        [ 6,  8], [ 6,  8], [ 8,  1], [ 8,  1], [ 6,  1], [ 6,  1], [ 6,  1], [ 6,  6], [ 6,  6], [ 6,  7], [ 7,  1],\n        [ 7,  1], [ 6, 16], [16,  1], [15,  8], [15,  8], [15,  8], [11, 17], [11, 17], [12,  8], [12,  8], [20,  9],\n        [20,  9], [19, 17], [19, 17], [13,  8], [13,  8], [13,  8], [14,  8], [14,  8], [ 5,  9], [ 5,  9]\n    ]\n}\n```\n\nIt is designed to run **alongside [oxfmt](https://oxc.rs/docs/guide/usage/formatter)**\n(which owns JS/TS/CSS/etc.), since neither oxfmt nor oxlint can format `.json`\nwith FracturedJson.\n\n## Browser playground\n\n**[▶ Try it live: select.github.io/fjson-fmt](https://select.github.io/fjson-fmt/)**\n\nA zero-backend playground lives in [`docs/`](docs/) and is served via GitHub\nPages. The same Rust engine is built for the browser\n(`wasm-pack build --target web`) and loaded as an ES module — the whole thing\nis ~185 KB of WASM and runs entirely client-side, with a claymorphism UI and a\nlight/dark theme toggle.\n\n[![Playground](docs/screenshots/light.png)](https://select.github.io/fjson-fmt/)\n\n```sh\nnpm run build:web        # rebuild docs/pkg from the crate\nnpx serve docs           # preview locally, then open the printed URL\n```\n\nDeployed automatically on each `v*.*.*` release tag\n([`deploy-to-pages.yml`](.github/workflows/deploy-to-pages.yml)). Force a theme\nwith `?theme=light` or `?theme=dark`.\n\n## Install\n\n```sh\nnpm i -D fjson-fmt   # ships prebuilt WASM; no Rust toolchain needed\n```\n\n## Usage\n\n```sh\n# Format files in place (default)\nfjson-fmt \"**/*.json\"\n\n# Verify formatting (CI) - exits 1 if anything would change\nfjson-fmt --check \"**/*.json\"\n\n# List files that differ (no writing)\nfjson-fmt --list-different \"**/*.json\"\n\n# stdin → stdout\ncat data.json | fjson-fmt --stdin --indent 2\n\n# Format a file to stdout without modifying it\nnpx fjson-fmt --stdin \u003c example.json\n```\n\nRun alongside oxfmt:\n\n```jsonc\n// package.json\n{\n  \"scripts\": {\n    \"fmt\": \"oxfmt \u0026\u0026 fjson-fmt \\\"**/*.json\\\"\",\n    \"fmt:check\": \"oxfmt --check \u0026\u0026 fjson-fmt --check \\\"**/*.json\\\"\"\n  }\n}\n```\n\n## Programmatic API\n\nThe package is **isomorphic** - the same import works in Node and in the\nbrowser (or any bundler). Conditional `exports` route to a Node build (WASM\nloaded synchronously) or a web build (WASM fetched + instantiated once).\n\n```js\nimport { init, format, formatSync, engineVersion } from \"fjson-fmt\";\n\n// Portable: `format` is async and initializes the engine on first use.\nconst pretty = await format('{\"a\":[1,2,3],\"bb\":[44,55]}', {\n  max_total_line_length: 120,\n  indent_spaces: 2,\n});\n\n// Sync path: available immediately in Node; in the browser call `await init()`\n// first (it's idempotent), then `formatSync` is synchronous.\nawait init();\nconst out = formatSync(input, { number_list_alignment: \"right\" });\n```\n\n- **Node** resolves the `\"node\"` export (synchronous WASM); `formatSync` works\n  with no `init()`.\n- **Browsers / bundlers** (Vite, webpack 5, Rollup) resolve the `\"browser\"`\n  export; the `.wasm` is located via `new URL(..., import.meta.url)`, so no\n  extra loader config is needed.\n\nOption keys are the canonical snake_case `FracturedJsonOptions` names (see\n[`crate/src/options.rs`](crate/src/options.rs)); TypeScript types ship with the\npackage.\n\n## Options\n\nCLI flags (override config files):\n\n| Flag | Effect |\n|------|--------|\n| `--write` | Format in place (default) |\n| `--check` | Verify; exit 1 if any file would change |\n| `-l, --list-different` | List differing files; exit 1 if any |\n| `--stdin` | Read stdin, write formatted result to stdout |\n| `-c, --config \u003cpath\u003e` | Explicit config file |\n| `--no-config` | Skip config discovery |\n| `--indent \u003cn\u003e` | Spaces per indent (default 4) |\n| `--tabs` | Indent with tabs |\n| `--max-line \u003cn\u003e` | Max total line length (default 120) |\n| `--eol \u003clf\\|crlf\u003e` | Line ending style |\n| `--comments \u003cerror\\|remove\\|preserve\u003e` | Comment policy |\n| `--trailing` | Allow trailing commas in input |\n| `--no-final-newline` | Don't append a trailing newline |\n\n## Config files\n\nDiscovered by walking up from each file's directory (like fracjson):\n`.fracturedjson`, `.fracturedjson.jsonc`, `.fracturedjson.json`. Comments and\ntrailing commas are allowed. Keys map to `FracturedJsonOptions` and are\ncase-insensitive (snake_case, camelCase, PascalCase, and fracjson long names\nall work):\n\n```jsonc\n{\n  // .fracturedjson.jsonc\n  \"indent_spaces\": 2,\n  \"max_total_line_length\": 100,\n  \"comment_policy\": \"preserve\",\n  \"allow_trailing_commas\": true\n}\n```\n\nFull option list: see `crate/src/options.rs`.\n\n## Development\n\nRequires Rust + the `wasm32-unknown-unknown` target + `wasm-pack`, plus\n[pnpm](https://pnpm.io) for the Node tooling.\n\n```sh\nrustup target add wasm32-unknown-unknown\ncargo install wasm-pack   # or use the binary installer\npnpm install              # dev dependencies (release-it, etc.)\n\npnpm build:wasm           # rebuilds pkg/ from crate/\npnpm test                 # node --test (CLI/engine glue, no toolchain)\npnpm test:engine          # cargo test - FracturedJson engine suite (needs Rust)\npnpm test:all             # both of the above\n```\n\n### Releasing\n\nReleases are cut with [release-it](https://github.com/release-it/release-it)\n(conventional-changelog, angular preset). It runs the full test suite, bumps the\nversion, updates `CHANGELOG.md`, tags, pushes, creates a GitHub Release, and\npublishes to npm. The `release` script injects a `GITHUB_TOKEN` from the `gh`\nCLI automatically, so you just run:\n\n```sh\npnpm release              # interactive; or: pnpm release --ci patch|minor|major\n```\n\n### Engine test suite\n\nThe Rust engine is verified by the FracturedJson port's integration test suite\n(vendored from `fcoury/fracturedjson-rs`, which itself tracks j-brooke's\ncross-implementation \"universal\" tests). It lives in `crate/tests/` and runs\nagainst the standard shared fixtures in `test/StandardJsonFiles/` and\n`test/FilesWithComments/` (from `j-brooke/FracturedJsonJs`):\n\n```sh\npnpm test:engine          # or: cargo test --manifest-path crate/Cargo.toml\n```\n\nThe prebuilt `pkg/` (WASM + JS glue) is committed so the CLI works without a\nRust toolchain.\n\n## License\n\nMIT. The vendored engine in `crate/src/*.rs` (except `lib.rs`) is from\n`fcoury/fracturedjson-rs`, MIT © Felipe Coury - see `crate/UPSTREAM-LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselect%2Ffjson-fmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselect%2Ffjson-fmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselect%2Ffjson-fmt/lists"}