Hjson, the Human JSON

A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments.

NPM Maven Central PyPI nuget Packagist crate Go Pkg gem


Comments, yay!

"What exactly is this value? A comment would help!"

Sure, comments allow you to document your data.

  # specify rate in requests/second
  "rate": 1000

  // prefer c-style comments?
  /* feeling old fashioned? */


"Why do I have to place key names in quotes?"

Glad you asked. Actually you don't need to do that!

  key: "value"


"Now I forgot the comma at the end."

So you did. But Hjson does not mind as long as you put each value on a new line.

  one: 1
  two: 2
  three: 4 # oops


"Come to think of it, why do I have to place strings in quotes?"

You are right. Let's make quotes for strings optional as well.

  text: look ma, no quotes!

  # To make your life easy, put the next
  # value or comment on a new line.
  # It's also easier to read!


"When there are no quotes, do I need escapes?"

No, escapes are gone from unquoted strings.

  # write a regex without escaping the escape
  regex: ^\d*\.{0,1}\d+$

  # quotes in the content need no escapes
  inject: <div class="important"></div>

  # inside quotes, escapes work
  # just like in JSON
  escape: "\\ \n \t \""


"Multiline strings are kind of hard to read."

"I wonder\nwhy you\nsay that." Hjson will let you write them with proper whitespace handling.

    JSON I love you.
    But strangled is my data.
    This, so much better.


"Are you joking? You can't remove the braces!"

The most common case is to start the config with an object. In this case you may omit the braces for the root object.

// this is a valid config file
joke: My backslash escaped!


"So this is Hjson."

You like it? Please go ahead and star it, then ask the developers of your favorite application to add Hjson support!


No? Are you a skeptic?

Look at nice Syntax diagrams, Download or read the FAQ.

// for your config
// use #, // or /**/ comments,
// omit quotes for keys
key: 1
// omit quotes for strings
string: contains everything until LF
// omit commas at the end of a line
cool: {
  foo: 1
  bar: 2
// allow trailing commas
list: [
// and use multiline strings
  My half empty glass,
  I will fill your empty half.
  Now you are half full.
Syntax Download FAQ Try It! Feedback History US EU