toon-format/toon · error · ToonDecodeError
Blank lines inside ${context} are not allowed in strict mode
Error message
Blank lines inside ${context} are not allowed in strict mode What it means
Thrown by validateNoBlankLinesInRange when strict-mode decoding finds a blank line strictly between the start and end of a keyed object, tabular array, or list array block. TOON treats blank lines inside multi-line structures as structurally ambiguous in strict mode, since they could merge or split blocks. The error reports the first offending blank line. Only fires when strict is true; the function returns early otherwise.
Source
Thrown at packages/toon/src/decode/validation.ts:68
}
}
export function validateNoBlankLinesInRange(
startLine: number,
endLine: number,
blankLines: BlankLineInfo[],
strict: boolean,
context: string,
): void {
if (!strict)
return
const firstBlank = blankLines.find(
blank => blank.lineNumber > startLine && blank.lineNumber < endLine,
)
if (firstBlank) {
throw new ToonDecodeError(
`Blank lines inside ${context} are not allowed in strict mode`,
{ line: firstBlank.lineNumber },
)
}
}
// #endregion
// #region Row classification helpers
/** Checks if a line is a data row (vs a key-value pair) in a tabular array. */
export function isDataRow(content: string, delimiter: Delimiter): boolean {
const colonPos = findUnquotedChar(content, COLON)
const delimiterPos = findUnquotedChar(content, delimiter)
if (colonPos === -1) {
return true
}View on GitHub (pinned to 604eac266e)
Solutions
- Remove the blank line(s) inside the array/object block
- Decode with { strict: false } if blank-line tolerance is acceptable
- Run a preprocessor that strips blank lines within indentation blocks before decoding
Example fix
// before items[2]: - a - b // after items[2]: - a - b
Defensive patterns
Strategy: validation
Validate before calling
const clean = input.split('\n').filter((l, i, a) => !(l.trim() === '' && insideBlock(a, i))).join('\n') Try / catch
try { decode(input, { strict: true }) } catch (e) { if (e instanceof ToonDecodeError && e.message.includes('Blank lines inside')) console.error('blank line at line', e.line?.lineNumber, '— strip blank lines inside blocks') } Prevention
- Never insert blank lines inside array/object blocks in TOON files
- Configure editors/formatters not to inject blank lines in .toon files
- Strip blank lines programmatically when accepting human-edited TOON
- Or decode with strict:false if blank-line tolerance is desired
When it happens
Trigger: Decoding TOON input with strict:true containing an empty line inside a keyed object, tabular array body, or list-form array body (decodeKeyedObject / decodeTabularArray / decodeListArray).
Common situations: Humans hand-editing TOON for readability and inserting separator blank lines; templating tools or editors that add trailing blank lines between blocks; concatenating chunks that each end with a newline.
Related errors
- Expected ${expected} ${itemType}, but got ${actual}
- Top-level document must start with a key-value or array-head
- Indentation depth jump: expected depth ${parentDepth + 1}, b
- Unexpected bare token line outside root primitive position
- Unexpected content after the document root
AI-assisted analysis of toon-format/toon@604eac266e (2026-08-31).
Data as JSON: /api/errors/44434e7e3531d787.
Report an issue: GitHub.