Skip to content

outbrowsed/csson

CSSON

license stars forks cdn badge

CSSON is a superset of JSON designed to make configuration and styling files more flexible. It allows:

  • Comments (single line // or jsdoc /* */)
  • Optional semicolons
  • Units like px, %, em
  • Hex colors
  • Easy parsing and stringifying

Perfect for configs, themes, and dynamic settings in js projects.


Demo: Demo


Features

  • Allows comments
  • css like syntax
  • Can be parsed and stringified with js similar to json
  • Case insensitive parser available (can be used as CSSON.funct or csson.funct)
  • Lightweight and fast

Installation

Include via es Module:

import { CSSON } from "https://cdn.jsdelivr.net/gh/outbrowsed/csson@main/src/index.min.mjs";

Usage

Parsing CSSON

import { CSSON } from "https://cdn.jsdelivr.net/gh/outbrowsed/csson@main/src/index.min.mjs";

const text = `
theme {
  color: #ff0000;
  fontSize: 16px;
  darkMode: true;
}
users [
  "alice",
  "bob"
]
`;

const parsed = CSSON.parse(text);
console.log(parsed);

Stringifying it

const obj = {
  theme: { color: "#ff0000", fontSize: "16px", darkMode: true },
  users: ["alice", "bob"]
};

const str = CSSON.stringify(obj);
console.log(str);

Features Demonstrated

  • Comments

// this is a line comment
/* this is a block (jsdoc) comment */
theme {
  color: #000;
}
  • Units and colors

theme {
  fontSize: 16px;
  margin: 10%;
  color: #ff00ff;
}
  • Arrays

users [
  "alice",
  "bob",
  "charlie"
]
  • Case insensitive keys

THEME {
  COLOR: #fff;
}

Advanced

  • Nested objects
  • Mix of arrays and objects
  • Supports all json primitive types + comments and units
  • Case insensitive parsing: CSSON.parse will accept keys in any casing

License

AGPL v3 License © 2025 OutBrowsed https://www.gnu.org/licenses/agpl-3.0.txt

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published