Skip to content

Instantly share code, notes, and snippets.

@DamianEdwards
Last active May 11, 2026 01:14
Show Gist options
  • Select an option

  • Save DamianEdwards/31d2457737304ca73556 to your computer and use it in GitHub Desktop.

Select an option

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!
}
@cntrump

cntrump commented Dec 28, 2020

Copy link
Copy Markdown

test JSONC

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

test JSON5

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

@fraune

fraune commented May 7, 2021

Copy link
Copy Markdown
{
    "hello": 123
}

@MistEO

MistEO commented Jan 7, 2022

Copy link
Copy Markdown

cool!

@dantebarba

Copy link
Copy Markdown

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

@CryDeTaan

CryDeTaan commented Oct 10, 2022

Copy link
Copy Markdown

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

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

@dantebarba

Copy link
Copy Markdown

@CryDeTaan thanks!

@ElectricRCAircraftGuy

ElectricRCAircraftGuy commented Jan 25, 2023

Copy link
Copy Markdown

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

@whyboris

whyboris commented Jun 2, 2023

Copy link
Copy Markdown

Testing today:

```json

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

```jsonc

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

```json5

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

@tskxz

tskxz commented Nov 6, 2024

Copy link
Copy Markdown

testing

{
  "test": 1234 // using jsonc
}

@atticus-arctiq

Copy link
Copy Markdown

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!
}

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