| Internet-Draft | MaSON | June 2026 |
| Lee | Expires 30 December 2026 | [Page] |
This document defines MaSON (Markdown Structured Object Notation), a lightweight data serialization format that maps standard Markdown syntax trees into structured key-value objects. MaSON is designed to maximize human readability and LLM token efficiency by eliminating bracket-based nesting and strict indentation rules.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 30 December 2026.¶
Copyright (c) 2026 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
Data serialization formats play a critical role in configuration, distributed systems, and application state management. Traditional formats such as JSON (RFC 8259) offer deterministic parsing but present syntax overhead (e.g., explicit braces, quotation marks, and strict trailing comma rules) that impairs manual, human-authored editing. Alternative human-readable formats, notably YAML, resolve bracket verbosity but introduce structural fragility through strict multi-space indentation constraints.¶
Concurrently, the rise of Large Language Models (LLMs) has introduced a new serialization constraint: token optimization. Repetitive structural characters in JSON and YAML consume valuable context window resources when data structures are injected into generative AI system prompts.¶
This document defines MaSON (Markdown Structured Object Notation), a format designed to bridge human readability, machine parsing efficiency, and token density. MaSON repurposes ubiquitous Markdown (RFC 7763) layout paradigms—specifically headers and list delimiters—to establish object hierarchies without syntax-heavy nesting markers.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
This specification intentionally assigns structured, machine-readable data serialization semantics to Markdown heading syntax beyond the purely presentational or structural document behaviors defined in RFC 7763. While a MaSON document remains syntactically valid Markdown, its document tree is explicitly mapped to associative data structures rather than an HTML visual layout.¶
The design of MaSON is governed by the following core architectural principles:¶
MaSON documents MUST be encoded using UTF-8. Line endings MUST be represented by a single Carriage Return and Line Feed (CRLF) sequence or a single Line Feed (LF) character. The parser MUST normalize line endings to a single uniform delimiter prior to processing.¶
The formal grammar rules specified via ABNF in Section {{formal-grammar}} describe the format's lexical structure using 8-bit octets. When parsing multi-byte sequences representing valid UTF-8 encoded Unicode scalar values outside the standard ASCII range, the parser MUST treat any continuous block of non-ASCII multibyte octets as a valid literal character sequence within a header key or property value stream.¶
Lines where the first non-whitespace character consists of a double forward-slash sequence ("//") MUST be treated as comment streams. Parsers MUST ignore comments and blank whitespace lines during lexical token processing.¶
Object nesting depth and scope are defined structurally by Markdown heading tokens.¶
The document root represents an implicit top-level associative array (object). A heading line beginning with one or more '#' characters followed by exactly one space character (0x20) MUST introduce a new nested object scope.¶
The number of '#' characters determines the absolute nesting depth:¶
Properties within a structural scope MUST be declared as a single-line key-value pair separated by a colon character (0x3A).¶
To permit structural characters inside property values or header keys, the backslash character ("\", 0x5C) MUST act as an escape character. The sequence ":" explicitly escapes a colon separator, "#" escapes a header token, and "\" escapes the backslash itself. Parsers MUST resolve these escape sequences to their literal equivalents during token assembly.¶
Sequential lines beginning with an asterisk ('*', 0x2A) or a hyphen ('-', 0x2D) followed by exactly one space character (0x20) MUST be parsed as sequential array items.¶
To prevent structural ambiguity when constructing arrays of complex objects, a header key MAY append an explicit array suffix consisting of opening and closing square brackets ("[]", 0x5B 0x5D).¶
When an explicit array suffix is encountered:¶
The syntax of a MaSON document is defined formally using Augmented Backus-Naur Form (ABNF) as specified in RFC 5234 [RFC5234]. The ABNF defines the strict lexical token boundaries of a MaSON stream. The semantic construction of hierarchical object depths, structural array appending, and state stack validation based on these tokens MUST be governed exclusively by the processing rules defined in Section {{processing}}.¶
mason-doc = *(section / kv-pair / array-list / empty-line / comment) section = header-marker SP header-key [array-suffix] CRLF header-marker = 1*6"#" array-suffix = "[]" kv-pair = inline-key ":" [SP] value CRLF inline-key = 1*(ALPHA / DIGIT / "-" / "_") header-key = inline-key *(1*SP inline-key) value = *(escaped-char / literal-char / utf8-scalar) escaped-char = "\" ( ":" / "#" / "\" ) literal-char = %x20-5B / %x5D-7E ; Printable ASCII VCHAR and SP, omitting \ utf8-scalar = %x80-FF ; Raw tracking slice for multi-byte UTF-8 streams array-list = 1*(list-marker SP value CRLF) list-marker = "*" / "-" comment = *SP "//" *(literal-char / utf8-scalar) CRLF empty-line = *SP CRLF number = ["-"] 1*DIGIT ["." 1*DIGIT]¶
A MaSON parser MUST maintain an internal state stack to keep track of the active structural hierarchy while traversing a document linearly.¶
Values extracted from key-value properties or array lists MUST be evaluated against literal structural patterns to determine if they undergo data type coercion:¶
number rule defined in Section {{formal-grammar}} MUST be coerced directly to native floating-point or integer numeric signatures within the processing environment. Any token sequence containing characters deviating from that structure MUST NOT undergo numeric coercion and falls back cleanly to a string representation.¶
Parsers MUST strip leading and trailing horizontal whitespace (spaces 0x20 and horizontal tabs 0x09) from both property keys and property values prior to evaluation or storage. Internal whitespace within a value payload MUST be preserved explicitly.¶
If a document contains duplicate inline property keys within the same active object scope, the parser MUST enforce a last-assignment-wins strategy, where the final parsed assignment value overwrites any preceding declaration.¶
Conversely, if a nested sub-header configuration path matches a path that has been declared previously in the document stream, the parser MUST execute a deep recursive merge of the subsequent properties into the existing structure rather than overwriting or purging the original object hierarchy. If a collision occurs between identical inline scalar keys inside those recursively merged header scopes, the final assignment declaration takes precedence.¶
Because MaSON determines structural depth and nesting scope by the linear accumulation of heading tokens (the '#' character), naive implementations relying on recursive parsing strategies or unbounded internal state stacks are vulnerable to stack overflow or out-of-memory errors.¶
An attacker could craft a malicious MaSON document consisting of thousands of deeply nested sequential headers (e.g., repeating incrementing sequences of '#', '##', '###', etc.) or exceptionally long continuous lines of a single token archetype. Implementations MUST enforce an upper limit on maximum nesting depth (a RECOMMENDED default limit of 32 levels) and maximum single-line buffer lengths to guarantee deterministic termination and mitigate Denial of Service (DoS) vectors.¶
As outlined in Section {{syntax}}, parsers are expected to automatically coerce primitive string sequences matching boolean or numeric literal patterns into native equivalents. Implementations MUST validate that incoming token sequences do not trigger prototype pollution or unexpected type mutation behaviors within the execution environment.¶
Furthermore, because MaSON documents eliminate explicit enclosing string delimiters for property values, applications consuming data from unvetted MaSON inputs MUST validate that payload string values do not inadvertently mirror structural control characters (such as colons or heading markers) that could be re-serialized to inject malicious keys into a downstream application state.¶
MaSON implementations handling complex inline values or embedded code blocks MUST treat the underlying isolated content strictly as static string fragments. Parsers MUST NOT evaluate or execute code blocks embedded within a document stream. Applications displaying or executing data extracted from a MaSON payload MUST apply contextual sanitization to prevent downstream Cross-Site Scripting (XSS) or command injection vulnerabilities.¶
This document requests the registration of a new media type and file extension in accordance with the procedures defined in RFC 6838 [RFC6838].¶
Type name: application Subtype name: mason Required parameters: None Optional parameters: charset (The value MUST be "utf-8") Encoding considerations: binary (UTF-8 encoded text) Security considerations: See Section 5 of this document. Interoperability considerations: MaSON is designed for cross-platform data interchange across server, browser, and language-model environments. Published specification: This document. Applications that use this media type: General-purpose software systems, system orchestration configuration tooling, and large language model prompt frameworks.¶
The standard file extensions designated for MaSON structured data documents are ".mason" and ".mson".¶
The following sample demonstrates a typical MaSON configuration input containing explicit primitives, lists, and structural scope depth nesting.¶
# Server Setup debugMode: false maxRetries: 5 # Servers * [https://api.prod.coolapp.com](https://api.prod.coolapp.com) * [https://api.backup.coolapp.com](https://api.backup.coolapp.com) # Database driver: postgres ## Credentials user: admin host: localhost¶
An RFC-compliant MaSON parser tracking the stack shifts and types outlined in this specification MUST map the source text above directly into the following equivalent JSON structure:¶
{
"Server Setup": {
"debugMode": false,
"maxRetries": 5
},
"Servers": [
"[https://api.prod.coolapp.com](https://api.prod.coolapp.com)",
"[https://api.backup.coolapp.com](https://api.backup.coolapp.com)"
],
"Database": {
"driver": "postgres",
"Credentials": {
"user": "admin",
"host": "localhost"
}
}
}
¶
The following sample illustrates the normative handling of nested object collections within sequential, recurring header declarations. Immediate sub-headers beneath an explicit array declaration ('[]') act as element boundary markers, instantiating a new object item within the collection array.¶
# Cluster Infrastructure environment: production ## Nodes[] ### Node Item host: compute-01.local capacity: 64 ### Node Item host: compute-02.local capacity: 128¶
An RFC-compliant MaSON parser tracking the active [] array scope stack MUST generate the following structure:¶
{
"Cluster Infrastructure": {
"environment": "production",
"Nodes": [
{
"host": "compute-01.local",
"capacity": 64
},
{
"host": "compute-02.local",
"capacity": 128
}
]
}
}
¶
The following sample illustrates the parsing response when an inline key-value property sequence is introduced directly below an explicit object array header without intermediate element boundary sub-headers, mapping to the behavior defined in Section {{array-suffixes}}.¶
# Users[] name: Alice age: 20¶
[
{
"name": "Alice",
"age": 20
}
]
¶
The following sample demonstrates how consecutive occurrences of a shared header identity path deeply combine nested property structures recursively based on the rules in Section {{duplicate-handling}}.¶
# Target Object ## Nested Child initial_key: true # Target Object ## Nested Child appended_key: false¶
{
"Target Object": {
"Nested Child": {
"initial_key": true,
"appended_key": false
}
}
}
¶
The structural efficiency metrics detailed below were generated empirically by processing a single, logically identical Agent Configuration payload compiled across formats and evaluated using OpenAI's production "cl100k_base" tokenization algorithm. The benchmark results are illustrative rather than normative.¶
| Format | Characters | Tokens (GPT-4) | Overhead Reduction |
|---|---|---|---|
| JSON | 194 | 58 | Baseline |
| YAML | 132 | 44 | 24.1% |
| MaSON | 98 | 31 | 46.5% |
In this specific benchmark, MaSON reduced token count by approximately 46.5% relative to the JSON baseline.¶
| Input Payload (MaSON) | Resulting Memory State (JSON) |
|---|---|
key: null
|
{ "key": null }
|
msg: err\: failed
|
{ "msg": "err: failed" }
|
hex: #ff0000
|
{ "hex": "#ff0000" }
|
# Empty Array[]
|
[]
|
The design decisions governing the assembly of MaSON are structured to address specific historical limitations encountered in standard data serialization languages:¶