{"id":15357178,"url":"https://github.com/gera2ld/format-json","last_synced_at":"2026-01-06T21:52:47.922Z","repository":{"id":77381342,"uuid":"283407964","full_name":"gera2ld/format-json","owner":"gera2ld","description":"Format JSON in different flavors","archived":false,"fork":false,"pushed_at":"2023-07-20T17:41:45.000Z","size":206,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T19:40:11.148Z","etag":null,"topics":["formatter","javascript","json"],"latest_commit_sha":null,"homepage":"https://gera2ld.github.io/format-json/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gera2ld.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-07-29T05:34:18.000Z","updated_at":"2025-03-04T12:50:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"19a63c9a-bbd0-4b9f-9cb3-268b830c3ecb","html_url":"https://github.com/gera2ld/format-json","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"d157df68aa2ff842a99c03ee7929db8fd2c80f88"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fformat-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fformat-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fformat-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fformat-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gera2ld","download_url":"https://codeload.github.com/gera2ld/format-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910366,"owners_count":20692433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["formatter","javascript","json"],"created_at":"2024-10-01T12:33:42.816Z","updated_at":"2026-01-06T21:52:47.889Z","avatar_url":"https://github.com/gera2ld.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @gera2ld/format-json\n\n![NPM](https://img.shields.io/npm/v/@gera2ld/format-json.svg)\n![License](https://img.shields.io/npm/l/@gera2ld/format-json.svg)\n![Downloads](https://img.shields.io/npm/dt/@gera2ld/format-json.svg)\n\nFormat JSON in different flavors.\n\n## Features\n\n- Format as JSON or JavaScript, either compact or indented\n- Highlight nodes by changing the output on render\n\n## Installation\n\n```sh\n$ yarn add @gera2ld/format-json\n```\n\n## Usage\n\n```js\nimport { format, ItemTypes } from '@gera2ld/format-json';\n\nconst data = {/* … */};\nconst jsonOptions = {\n  indent: 0,\n  quoteAsNeeded: false,\n  quote: '\"',\n  trailing: false,\n  template: false,\n};\nconsole.log('format as JSON:', format(data, jsonOptions));\n\nconst jsOptions = {\n  indent: 2,\n  quoteAsNeeded: true,\n  quote: '\\'',\n  trailing: true,\n  template: true,\n};\nconsole.log('format as JavaScript', format(data, jsOptions));\n\nconst highlightOptions = {\n  onData(item) {\n    // if the property name is 'highlight', wrap it with `\u003cem\u003e...\u003c/em\u003e`\n    if (item.path[item.path.length - 1] === 'highlight' \u0026\u0026 item.type === ItemTypes.KEY) {\n      item.data = [\n        { value: '\u003cem\u003e' },\n        ...item.data,\n        { value: '\u003c/em\u003e' },\n      ];\n    }\n  },\n};\nconsole.log('highlight values', format(data, highlightOptions));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fformat-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgera2ld%2Fformat-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fformat-json/lists"}