My name is JSON, UX JSON: a user friendly format for configuration file

♻ The good, the bad: it’s the same one

I must confess something: I both love and hate JSON 🤒

Using JSON to exchange data suits me just fine. BUT when I manually edit a json file, I’m something like ☹☹☹.  Quotes and comas are painful to be handled manually. And I miss comments.  Hoppefully, thete’s more use friendly format for configuration file.

♻ Humanised config files: the good, the good and the good

YAMLCSON, JSON5 and HJSON offers more user friendly configuration files. To use a buzzword, they offer a better user experience. I personally use HJSON, but it’s a subjective choice: they both do the job, choosing between them is rather a matter of taste.

HJSON is introduced as “A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments.”.  Fewer mistakes: not only using HJSON syntax is less boring but it requires less headace to fix it.

HJSON syntax matches what I’m looking for:

  • Comments are allowed
  • Quotes and commas are no more required
  • Bonus: brackets is no more needed for root object

Here is an example that show all the features of human json:

// 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.

If you are interested you can go to the official Web site and find the library of your language (there’s lib for Java, Javascript, Python,  Go,…). I use the javascript one in my node projects without troubles.

♻ What’s missing

I’d like to have supports for date (even if, in javascript, moment can do the job), and, above all, a schema validator. I really find boring to write all validation manually, and even more boring to read a code that validate a config file (hopefully joi module exist).

♻ Conclusion

At this time of writing, I don’t know any config file format that suits me just fine. I choose hjson,  but, again, it’s a subjective choice: do your own research and choose what fees you best.

🙋 See you and have a nice code