Skip to content

Instantly share code, notes, and snippets.

@ThomasVille
Last active March 28, 2025 09:04
Show Gist options
  • Select an option

  • Save ThomasVille/54a9a8a89098385d451eea443b82dd9e to your computer and use it in GitHub Desktop.

Select an option

Save ThomasVille/54a9a8a89098385d451eea443b82dd9e to your computer and use it in GitHub Desktop.
Remove comments from JSON file
# This sed command removes every C-style single line comments (//) from a file that can contain strings delimited by `"`
# (intended for use with JSON files).
# So this JSON:
# {
# "app url": "https://www.example.com" // URL of the application
# }
# becomes:
# {
# "app url": "https://www.example.com"
# }
sed -re 's#^(([^"\n]*"[^"\n]*")*[^"\n]*)\/\/.*$#\1#'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment