{"id":15663249,"url":"https://github.com/nylen/node-json-align","last_synced_at":"2025-05-05T23:45:14.999Z","repository":{"id":10650928,"uuid":"12880463","full_name":"nylen/node-json-align","owner":"nylen","description":"Library and script to pretty-print JSON with values aligned together.","archived":false,"fork":false,"pushed_at":"2017-07-31T19:00:58.000Z","size":212,"stargazers_count":17,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T11:05:45.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nylen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-16T22:34:23.000Z","updated_at":"2022-08-04T15:00:29.000Z","dependencies_parsed_at":"2022-09-26T20:41:30.421Z","dependency_job_id":null,"html_url":"https://github.com/nylen/node-json-align","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylen%2Fnode-json-align","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylen%2Fnode-json-align/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylen%2Fnode-json-align/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylen%2Fnode-json-align/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nylen","download_url":"https://codeload.github.com/nylen/node-json-align/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596325,"owners_count":21773842,"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":[],"created_at":"2024-10-03T13:36:05.941Z","updated_at":"2025-05-05T23:45:14.980Z","avatar_url":"https://github.com/nylen.png","language":"JavaScript","readme":"#json-align [![Build status](http://img.shields.io/travis/nylen/node-json-align.svg?style=flat)](https://travis-ci.org/nylen/node-json-align) [![npm package](http://img.shields.io/npm/v/json-align.svg?style=flat)](https://www.npmjs.org/package/json-align)\n\nThis module provides a function and a command-line script that pretty-print\nJSON strings with consecutive values aligned at the same column for improved\nreadability.\n\nBefore:\n\n```js\n\n{\n    \"name\": \"json-align\",\n    \"author\": \"James Nylen \u003cjnylen@gmail.com\u003e\",\n    \"description\": \"Library and script to pretty-print JSON files with values aligned together.\",\n    \"version\": \"...\",\n    \"repository\": {\n        \"type\": \"git\",\n        \"url\": \"https://github.com/nylen/node-json-align\"\n    },\n...\n```\n\nAfter:\n\n```js\n\n{\n    \"name\"        : \"json-align\",\n    \"author\"      : \"James Nylen \u003cjnylen@gmail.com\u003e\",\n    \"description\" : \"Library and script to pretty-print JSON files with values aligned together.\",\n    \"version\"     : \"...\",\n    \"repository\"  : {\n        \"type\" : \"git\",\n        \"url\"  : \"https://github.com/nylen/node-json-align\"\n    },\n...\n```\n\nBased on [Douglas Crockford's `json2.js`](https://github.com/douglascrockford/JSON-js/blob/master/json2.js).\n\n##Usage\n\nIn code (first do `npm install json-align`):\n\n    JSON.stringifyAligned = require('json-align');\n\nOn the command line (first do `sudo npm install -g json-align`):\n\n    json-align --help\n\nThe command-line script will output to stdout unless the `-i`/`--in-place`\noption is given.\n\n##Parameters\n\n    JSON.stringifyAligned(obj, [replacer], [spaces], [alignAllValues])\n    // or\n    JSON.stringifyAligned(obj, alignAllValues, [spaces])\n\n - `replacer`: Like in `JSON.stringify`, this is a value transformation\n   function, or an array of properties to serialize.\n - `spaces`: Like in `JSON.stringify`, a number of spaces (or string) to indent\n   by (the default is 4)\n - `alignAllValues`: By default, a new alignment group will be started each\n   time an array or object value is encountered.  If this option is set to\n   `true`, then each object will have all of its values aligned together.\n\n##Examples\n\n```js\nJSON.stringifyAligned({abc: 1, defgh: 2})\n{\n    \"abc\"   : 1,\n    \"defgh\" : 2\n}\n```\n\n```js\nJSON.stringifyAligned({abc: 1, defgh: [2,3,4], ijk: 5})\n{\n    \"abc\"   : 1,\n    \"defgh\" : [\n        2,\n        3,\n        4\n    ],\n    \"ijk\" : 5   // Note that this value is not aligned with the first two,\n                // since there is an array or object value before it.\n}\n```\n\n```js\nJSON.stringifyAligned({abc: 1, defgh: [2,3,4], ijk: 5}, null, 2, true)\n{\n  \"abc\"   : 1,\n  \"defgh\" : [\n    2,\n    3,\n    4\n  ],\n  \"ijk\"   : 5\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylen%2Fnode-json-align","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnylen%2Fnode-json-align","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylen%2Fnode-json-align/lists"}