Dear developers,
Please don't use JSON for configuration files. It is intended for carrying data, and nothing else. Therefore, it is good at carrying data, and nothing else.

I strongly believe that anything that doesn't support comments shouldn't be used for configs. Comments are indispensable for short documentation, or putting a URL to proper documentation.

There are other plain text file formats better fit for this purpose, such as TOML, YAML, and even XML.

If you coded your program in JS, I understand that you might be inclined to use JSON. Maybe you want to reduce bloat or dependency by not including a TOML or YAML parser. But you are making it more difficult for us to contribute to your project, or fix something on our end.

It is quiet old too. Probably older than time itself given that it doesn't support date standards ISO 8601 or RFC 3339 out-of-the-box. That is because it doesn't need to, because it is not for configurations or manifests.

What is your favourite plain text format for configurations?
JSON
14.9%
TOML
34.9%
YAML
32%
Other (comment please)
18.3%
Poll ended at .

After reading so many replies, it is clear that way too many new variants of JSON were developed to make JSON do what it was never meant to do. JSON is for carrying data between server and client in JavaScript fashion. It is amazing for that purpose. After all, JS developers came to expect variable type errors to surface, and not worry about them.

This was already achieved with XML, but some people love to reinvent the tire, hence the JSON forks with comments i guess.

TOML would be horrible as a JS oriented data carrier.

TOML was meant to be a different thing, such as a well understood config format that is easily interpreted by both humans and machines. Semantics help avoid ambiguation. It ain't perfect.Lack of type declaration may get us sometimes. For instance, if people forget that phone and version "numbers" are actually strings, they may omit double qoutes causing them being interpreted as an integer, float or error.

But a comment line reminding us for such pitfall would go a long way.

Consider this:
distro_name = "Ubuntu"
distro_version = "14.10"
# Run this if you forgot your distro version: cat /etc/lsb-release | grep "RELEASE"
# Then enter version in double quotes.

TOML won't freak out like YAML if you have 8 of anything, or live in Norway. This doesn't mean that TOML is the most superior file format for configurations, XML is much better.

XML is the back bone of so many things you use everyday that if it had such pitfalls, world wide web would crash hourly. Its only short coming is human readability.
@murtezayesil I said YAML but I also use JSON a lot for the reasons you outlined above
@hryggrbyr @[email protected] voted YAML but not because I like it just config in JSON is just stupid and it because the dev wants to read the config not write it.

@tig @hryggrbyr

I asked what is your favourite file format for config files. In other words, which format you think should be the norm in IT industry.

@murtezayesil @hryggrbyr I don't really mind providing it is plain text and clearly documented. I don't care so much for rigid formatting or the formatting dictating the config.
@murtezayesil @hryggrbyr I mean we have never really fully nailed down email as a standard there are general accepted rules but nothing concrete so if we haven't done that I think a single config standard is nice idea but I doubt it will happen. I think we should strive for good behaviour in config files so plain text, human readable and human friendly remembering this is bit the user needs to deal with and may not be a programmer so no fiddly formatting please :)

@murtezayesil

XML for complicated configs

ini for simple configs

@charadon @murtezayesil this is the way. I would also add that a database would be optimal for *really really* complex configs.
@murtezayesil All mentioned formats have their shortcomings, from the list yaml is the least worst. My preference is a ini like text file
@murtezayesil of those listed, I like toml the best. My favorites though are https://kdl.dev and https://github.com/edn-format/edn
The KDL Document Language

kdl is a document language, mostly based on SDLang, with xml-like semantics that looks like you're invoking a bunch of CLI commands!

@murtezayesil

Python. Fed to eval(). Sue me.

@flbergerdev @murtezayesil *nervous laugh*
*Hides his python modules based config file approach under the mat*
GitHub - edn-format/edn: Extensible Data Notation

Extensible Data Notation. Contribute to edn-format/edn development by creating an account on GitHub.

GitHub

@murtezayesil of these three only TOML is intended to be a configuration language, but I would argue that *as a configuration language* Lua is better than TOML. That it also happens to be a programming language is a disadvantage for the use case of being a good configuration language, but I feel like its advantages outweigh that major disadvantage.

Second place is a bespoke config file format that looks like e.g. git-config or ssh's config language.

Third place is a sqlite3 file.

@murtezayesil
turtle (rdf). But i work very much with RDF graphs so getting information from and expressing information with them, you might have to get used to it.

So don't know if this is a better alternative for open source projects.

@murtezayesil just shell env variable syntax
@murtezayesil I’ll be the the guy who prefers XML.

@murtezayesil I'd say that depends on several things.

The one thing I was assuming was that I need to write and maintain the config file as a human. For that, I find TOML quite easy to write and read.

If your config files are (auto-)generated and read only by software, it really doesn't matter at all as long as it follows one standard IMO.

@publicvoit True to some degree. If config is auto generated, my local changes could get overwritten. I mean why not embrace Window's central registry like system in Linux. It is an industry standard.
But if software is telling me where the default config file is for advanced configuration, allowing me to set the path for its config file in its limited settings page or through CLI, there is a good chance this is not one of those cases.

@murtezayesil

> Window's central registry [...] It is an industry standard.

I'm not sure if this is standardized.

And: not every pattern is a sane way of doing things. Particularly when it comes from Microsoft. I can give you *lots* of examples where they did the most stupidest things where nobody is able to follow their reasoning. 🤷

@publicvoit Standard unfortunately doesn't always mean sane or smart way of doing things. That is because if enough people are doing something same way, it becomes a standard.
My point is that we should use raise awareness for using standards for the purposes they were meant to serve. Purpose of JSON is to carry data between server and client. A JSON file should die after carrying that data. Using it as a config file is stretching its purpose at best, and making configuring impossible at worst.

@murtezayesil I subscribe to your message.

> My point is that we should use raise awareness for using standards for the purposes they were meant to serve.

However, this would also "prevent" or "suppress" creative ways of (re-)using technology which is also an important aspect.

So unless there is an issue related, I would not stick to "this is how it was meant to be" without a good reason.

@murtezayesil @publicvoit We already have a "registry like system in Linux", it's Gnome's dconf, which Gnome-oriented software uses to store their settings.
@cesarb @publicvoit I am aware of that. But I often find registries crowded and overwhelming. Gnome registry however has description for its values, default value for resetting, range or list of acceptable values etc. And dconf-editor exposes them nicely. Kinda making me say, I wish all configuration systems were this helpful.
This can be somewhat achieved thanks to comments in TOML and YAML. But some file formats, such as JSON, were not designed to be used as configuration files, which is okay.
@murtezayesil I have a soft spot for HOCON (https://github.com/lightbend/config) 😊
GitHub - lightbend/config: configuration library for JVM languages using HOCON files

configuration library for JVM languages using HOCON files - lightbend/config

GitHub