{"id":21961855,"url":"https://github.com/trapcodeio/go-strip-json-comments","last_synced_at":"2026-02-27T20:03:14.281Z","repository":{"id":64297212,"uuid":"563504742","full_name":"trapcodeio/go-strip-json-comments","owner":"trapcodeio","description":"Strip comments from JSON. Lets you use comments in your JSON files!","archived":false,"fork":false,"pushed_at":"2022-11-10T04:35:07.000Z","size":97,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T13:08:45.959Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/trapcodeio.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":"2022-11-08T18:52:24.000Z","updated_at":"2024-10-21T12:26:07.000Z","dependencies_parsed_at":"2023-01-15T08:45:19.467Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/go-strip-json-comments","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fgo-strip-json-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fgo-strip-json-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fgo-strip-json-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fgo-strip-json-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/go-strip-json-comments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506542,"owners_count":21441796,"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-11-29T10:19:19.149Z","updated_at":"2026-02-27T20:03:09.243Z","avatar_url":"https://github.com/trapcodeio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-strip-json-comments\n\n[github](https://github.com/trapcodeio/go-strip-json-comments) | [pkg.go.dev](https://pkg.go.dev/github.com/trapcodeio/go-strip-json-comments)\n\n#### Note:\n\nThis is an exact port of Sindresorhus Nodejs [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) to\nGoLang.\n\n\n\n\u003e Strip comments from JSON. Lets you use comments in your JSON files!\n\nThis is now possible:\n\n```js\n{\n    // Rainbows\n    \"unicorn\"\n: /* ❤ */\n    \"cake\"\n}\n```\n\nIt will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error\npositions to remain as close as possible to the original source.\n\nAlso available as a [Gulp](https://github.com/sindresorhus/gulp-strip-json-comments)\n/[Grunt](https://github.com/sindresorhus/grunt-strip-json-comments)\n/[Broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.\n\n## Install\n\n```sh\ngo get github.com/trapcodeio/go-strip-json-comments\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/trapcodeio/go-strip-json-comments\"\n)\n\nfunc main() {\n\tjson := `{\n        // Rainbows\n        \"unicorn\": /* ❤ */ \"cake\"\n    }`\n\n\tfmt.Println(stripjsoncomments.Strip(json))\n\t//=\u003e{ \"unicorn\": \"cake\" }\n\n\t// with options\n\toptions := stripjsoncomments.Options{\n\t\tWhitespace:     false,\n\t\tTrailingCommas: true,\n\t}\n\n\tfmt.Println(stripjsoncomments.StripWithOptions(json, \u0026options))\n}\n```\n\n### Test\nClone repo and run\n```sh\ngo test -v\n```\nyou can also view them in this repo actions tab.\n\n### Benchmark\n\n```sh\ngo test -bench=. -count 5 -run=^#\n```\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/trapcodeio/go-strip-json-comments\ncpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz\nBenchmarkWithFiles/strip_JSON_comments-16                    332           3304452 ns/op\nBenchmarkWithFiles/strip_JSON_comments-16                    408           3759578 ns/op\nBenchmarkWithFiles/strip_JSON_comments-16                    289           3634032 ns/op\nBenchmarkWithFiles/strip_JSON_comments-16                    297           3826366 ns/op\nBenchmarkWithFiles/strip_JSON_comments-16                    338           3652408 ns/op\nBenchmarkWithFiles/strip_JSON_comments_without_whitespace-16                 621           1747448 ns/op\nBenchmarkWithFiles/strip_JSON_comments_without_whitespace-16                 639           1899337 ns/op\nBenchmarkWithFiles/strip_JSON_comments_without_whitespace-16                 652           1891341 ns/op\nBenchmarkWithFiles/strip_JSON_comments_without_whitespace-16                 766           1799857 ns/op\nBenchmarkWithFiles/strip_JSON_comments_without_whitespace-16                 699           1867128 ns/op\nBenchmarkWithFiles/strip_Big_JSON_comments-16                                  9         131861237 ns/op\nBenchmarkWithFiles/strip_Big_JSON_comments-16                                  8         138128030 ns/op\nBenchmarkWithFiles/strip_Big_JSON_comments-16                                  9         140734501 ns/op\nBenchmarkWithFiles/strip_Big_JSON_comments-16                                  8         126000649 ns/op\nBenchmarkWithFiles/strip_Big_JSON_comments-16                                  8         133652308 ns/op\nPASS\nok      github.com/trapcodeio/go-strip-json-comments    24.843s\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fgo-strip-json-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fgo-strip-json-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fgo-strip-json-comments/lists"}