Skip to content

Instantly share code, notes, and snippets.

@DamianEdwards
Last active November 6, 2024 21:20
Show Gist options
  • Save DamianEdwards/31d2457737304ca73556 to your computer and use it in GitHub Desktop.
Save DamianEdwards/31d2457737304ca73556 to your computer and use it in GitHub Desktop.
JSON comments on GH

What happens if you tell GitHub it's JSON

{
  "hello": "world" // I want my comments!
}

Use jsonc as the language instead

{
  "hello": "world" // I want my comments!
}

Or just tell GitHub it's JavaScript

{
  "hello": "world" // I want my comments!
}
{
"hello": "world" // I want my comments!
}
@benrudhart
Copy link

👍 cool! did you request a feature from github to enable comments in json code in markdown rendering?

@levrik
Copy link

levrik commented Mar 19, 2018

you can also tell GitHub to use json5 syntax highlighting.

@angelwing12
Copy link

I think this will help - https://jsonviewer.io/

@Tanja-4732
Copy link

+1 Modern problems require modern solutions.

@rachitchokshi
Copy link

2019 update: use jsonc rendering. i.e json with comments

@kylrth
Copy link

kylrth commented Jul 8, 2019

To allow jsonc rendering for JSON files in a GitHub Gist, give them the file extension .json5.

Copy link

ghost commented Dec 20, 2020

awesome

@cntrump
Copy link

cntrump commented Dec 28, 2020

test JSONC

{
  "hello": "world" // I want my comments!
}

test JSON5

{
  "hello": "world" // I want my comments!
}

@fraune
Copy link

fraune commented May 7, 2021

{
    "hello": 123
}

@MistEO
Copy link

MistEO commented Jan 7, 2022

cool!

@dantebarba
Copy link

Would be great to have key-value syntax highlighting just for readability purposes.

@CryDeTaan
Copy link

CryDeTaan commented Oct 10, 2022

@dantebarba one way to cheat it seems to be yaml
https://stackoverflow.com/a/58946269

{
  "hello": "world" # I want my comments!
}

@dantebarba
Copy link

@CryDeTaan thanks!

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Jan 25, 2023

Thanks! I just wrote about this here, and referenced you: Stack Overflow: Can comments be used in JSON?

@whyboris
Copy link

whyboris commented Jun 2, 2023

Testing today:

```json

{
  "hello": "world" // comment
}

```jsonc

{
  "hello": "world" // comment
}

```json5

{
  "hello": "world" // comment
}

@tskxz
Copy link

tskxz commented Nov 6, 2024

testing

{
  "test": 1234 // using jsonc
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment