{"id":17821519,"url":"https://github.com/a179346/json-sizeof","last_synced_at":"2025-07-02T12:35:00.210Z","repository":{"id":37822445,"uuid":"306580826","full_name":"a179346/json-sizeof","owner":"a179346","description":"Get the byte size of an object after JSON.stringify","archived":false,"fork":false,"pushed_at":"2022-12-27T09:05:11.000Z","size":161,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-27T17:14:47.270Z","etag":null,"topics":["bytes","javascript","json","json-byte","json-size","json-sizeof","nodejs","npm","npm-package","object","object-byte","object-size","size","sizeof","typescript"],"latest_commit_sha":null,"homepage":"","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/a179346.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}},"created_at":"2020-10-23T08:54:28.000Z","updated_at":"2024-10-07T02:06:12.000Z","dependencies_parsed_at":"2023-01-31T03:00:58.515Z","dependency_job_id":null,"html_url":"https://github.com/a179346/json-sizeof","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/a179346/json-sizeof","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fjson-sizeof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fjson-sizeof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fjson-sizeof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fjson-sizeof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a179346","download_url":"https://codeload.github.com/a179346/json-sizeof/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a179346%2Fjson-sizeof/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263141100,"owners_count":23420000,"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":["bytes","javascript","json","json-byte","json-size","json-sizeof","nodejs","npm","npm-package","object","object-byte","object-size","size","sizeof","typescript"],"created_at":"2024-10-27T17:17:58.109Z","updated_at":"2025-07-02T12:35:00.183Z","avatar_url":"https://github.com/a179346.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003e ⭕ json-sizeof ⭕\u003c/h1\u003e\n\n\u003cp\u003e\n  \u003ca href=\"https://github.com/a179346/json-sizeof/actions/workflows/test.yml\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://github.com/a179346/json-sizeof/actions/workflows/test.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/json-sizeof\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/npm/v/json-sizeof?maxAge=3600)\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/json-sizeof#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/json-sizeof/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/a179346/json-sizeof/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/a179346/json-sizeof\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003e Get the byte size of an object after JSON.stringify\n\n## 📩 Installation\n```\nnpm i json-sizeof\n```\n\n## 🔗 Links\n[npm package](https://www.npmjs.com/package/json-sizeof)\n\u003cbr\u003e\n[Github page](https://github.com/a179346/json-sizeof)\n\n## 📋 Usage\n#### Example\n```js\nconst { jsonSizeOf } = require('json-sizeof');\n\nconst obj = {\n  str1: 'I am a string!',\n  obj1: {\n    str2: 456,\n    obj2: null,\n    obj3: undefined\n  },\n};\n\nconst bytes = jsonSizeOf(obj);\n// expected 57\n```\n\n## 📌 Why\njsonSizeOf(obj) equals to Buffer.byteLength(JSON.stringify(obj)).\n\u003cbr\u003e\nbut is **faster** and **less likely to cause \"Javascript heap out of memory\"**\n```js\nconst obj = {};\nfor (let i = 0;i \u003c 8000000;i++) {\n  obj['test' + i] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n}\n\n// expected: 342888891\njsonSizeOf(obj);\n\n// The following line will cause \"JavaScript heap out of memory\" fatal error\n// if you do not maually increase the memory usage of node app.\nBuffer.byteLength(JSON.stringify(obj));\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa179346%2Fjson-sizeof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa179346%2Fjson-sizeof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa179346%2Fjson-sizeof/lists"}