Stop wasting your LLM context window on standard JSON and YAML

DustLee1 pts0 comments

mason-parser - npm

npm

Search<br>Sign UpSign In

mason-parser

1.0.0 • Public • Published 39 minutes ago<br>Readme<br>Code Beta<br>0 Dependencies<br>0 Dependents<br>1 Versions<br>mason-parser

Markdown Structured Object Notation (MSON) — The human-centric serialization format that bridges natural markdown visual structure and lightweight, structured JSON.

MSON is a super-lightweight alternative to JSON/YAML/TOML designed specifically for configuration files , static content documents , and efficient Prompting / Context storage for Large Language Models (LLMs) . It reduces token overhead by 15% to 30% compared to standard JSON by replacing heavy syntactic delimiters (such as braces, brackets, and redundant key quotes) with standard, beautiful Markdown headers and itemized lists.

🚀 Key Advantages

Zero-Bracket Nesting: Structure child objects implicitly via standard Markdown headings (#, ##, ###).

Natural Array Triggers: Bulleted lists (*, -, +) automatically morph parent containers into ordered arrays.

Implicit Type Casting: Native scanning of numbers, floats, booleans (true/false), and null values without tedious string conversions.

LLM-Token Friendly: Eliminates redundant nested syntax, resulting in massive prompt and response cost reductions when feeding data to Gemini, GPT, or Claude.

Bi-directional Integrity: Safely stringifies complex objects back to MSON, complete with sorted parameters and beautiful spaced structure.

📦 Installation

npm install mason-parser

🛠️ Usage Example

1. Write an .mson File

title: Server Setup<br>version: 1.0.3<br>debugMode: false<br>maxRetries: 5

# Servers<br>* https://api.prod.coolapp.com<br>* https://api.backup.coolapp.com

# Database<br>driver: postgres

## Credentials<br>user: admin<br>host: localhost

## Backups<br>* BackupNode1<br>* BackupNode2

2. Parse MSON into JSON

import { parse } from 'mason-parser';<br>import fs from 'fs';

const msonText = fs.readFileSync('config.mson', 'utf-8');<br>const data = parse(msonText);

console.log(data);<br>/*<br>title: "Server Setup",<br>version: "1.0.3",<br>debugMode: false,<br>maxRetries: 5,<br>Servers: [<br>"https://api.prod.coolapp.com",<br>"https://api.backup.coolapp.com"<br>],<br>Database: {<br>driver: "postgres",<br>Credentials: {<br>user: "admin",<br>host: "localhost"<br>},<br>Backups: [<br>"BackupNode1",<br>"BackupNode2"<br>*/

3. Stringify back to MSON

import { stringify } from 'mason-parser';

const config = {<br>appName: "TestApp",<br>active: true,<br>nodes: [101, 102]<br>};

const msonString = stringify(config);<br>console.log(msonString);<br>/*<br>appName: TestApp<br>active: true

# nodes<br>* 101<br>* 102<br>*/

📜 Grammar & Formatting Rules

Parameters: Represented by key: value pairs. Value is implicitly parsed as a primitive (number, boolean, null, or string).

Quoting: To force any numerical sequence or boolean value to stay a string, simply wrap it in quotes: zipCode: "16801".

Headings:

Any property before the first # is declared at the root level.

# headings denote level 1 object parameters.

## headings nest themselves inside the active # parent object.

If there is no active # heading, ## headings fall back to root.

Lists: Bullet elements (*, -, +) immediately turn the nearest active heading key into an ordered array of typed primitives or objects.

⚖️ License

Licensed under the Apache-2.0 License.

Readme<br>Keywords<br>mason<br>mson<br>markdown<br>json<br>parser<br>serializer<br>yaml<br>toml<br>configuration<br>llm<br>token-saving

Package Sidebar<br>Install<br>npm i mason-parser

Version<br>1.0.0

License<br>Apache-2.0

Last publish<br>39 minutes ago

Collaborators

lemonelabs

Analyze security with SocketCheck bundle size View package health Explore dependencies<br>Report malware

mason parser mson json markdown headings

Related Articles