
Security News
RubyGems Adds Cooldown Feature to Bundler for Newly Published Gems
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.
Path-Level Object Oriented Notation - The Most Token-Efficient Format for Nested Hierarchical Data
The Most Token-Efficient Format for Nested Hierarchical Data
PLOON achieves 49% token reduction vs JSON and 14% better than TOON through dual path notation (depth:index for arrays, depth for objects) and single schema declaration, optimized for deeply nested structures with full nested object support.
Credits
Inspired by TOON Format. PLOON offers an alternative approach using path-based hierarchy instead of indentation, achieving comparable token efficiency with different trade-offs.
When sending data to LLMs, every token counts. PLOON optimizes hierarchical data by:
| Metric | vs JSON | vs XML | vs YAML | vs TOON |
|---|---|---|---|---|
| File Size (Standard) | 66.2% ↓ | 62.4% ↓ | 48.5% ↓ | 36.0% ↓ |
| File Size (Minified) | 66.5% ↓ | 62.8% ↓ | 49.0% ↓ | 36.5% ↓ |
| Token Count (Standard) | 49.1% ↓ | 48.7% ↓ | 24.8% ↓ | 14.1% ↓ |
| Token Count (Minified) | 49.1% ↓ | 48.7% ↓ | 24.8% ↓ | 14.1% ↓ |
| Round-Trip Accuracy | - | - | - | 100% (5/5) |
PLOON beats TOON on BOTH metrics:
ROI Example (10M API calls/month):
✅ Nested objects support: Arrays #() and Objects {} notation
✅ Multi-format input: JSON, XML, YAML → PLOON
✅ Dual output: Standard (readable) or Compact (efficient)
✅ Fully configurable: Custom delimiters, separators, markers
✅ Zero dependencies: Native JSON parsing
✅ TypeScript: Full type safety
✅ Tree-shakeable: Import only what you need
✅ CLI tool: Convert files from command line
# Core library
npm install ploon
# or
pnpm add ploon
# or
yarn add ploon
# CLI tool (optional)
npm install -g ploon-cli
import { stringify, minify, fromJSON } from 'ploon'
// Your data
const data = {
products: [
{ id: 1, name: 'Shirt', price: 29.99 },
{ id: 2, name: 'Pants', price: 49.99 }
]
}
// Convert to PLOON Standard (human-readable)
const ploon = stringify(data)
console.log(ploon)
// [products#2](id,name,price)
//
// 1:1|1|Shirt|29.99
// 1:2|2|Pants|49.99
// Minify for production (token-optimized)
const compact = minify(ploon)
console.log(compact)
// [products#2](id,name,price);;1:1|1|Shirt|29.99;1:2|2|Pants|49.99
// 62.7% smaller than JSON! 🎉
stringify(data, options?)Convert JavaScript object to PLOON string.
import { stringify } from 'ploon'
const ploon = stringify(data, {
format: 'standard', // or 'compact'
config: {
fieldDelimiter: '|',
pathSeparator: ':',
// ... other options
}
})
parse(ploonString, options?)Convert PLOON string to JavaScript object.
import { parse } from 'ploon'
const data = parse(ploonString, {
strict: true, // Validate schema
config: { /* custom config */ }
})
minify(ploonString)Convert Standard format → Compact format (newlines → semicolons).
import { minify } from 'ploon'
const compact = minify(standardPloon)
// Reduces tokens further!
prettify(ploonString)Convert Compact format → Standard format (semicolons → newlines).
import { prettify } from 'ploon'
const readable = prettify(compactPloon)
// Makes debugging easier!
fromJSON(jsonString)Parse JSON string to object (uses native JSON.parse).
import { fromJSON, stringify } from 'ploon'
const obj = fromJSON('{"name": "John"}')
const ploon = stringify(obj)
fromXML(xmlString)Parse XML string to object (uses fast-xml-parser).
import { fromXML, stringify } from 'ploon'
const obj = fromXML('<root><name>John</name></root>')
const ploon = stringify(obj)
fromYAML(yamlString)Parse YAML string to object (uses yaml).
import { fromYAML, stringify } from 'ploon'
const obj = fromYAML('name: John\nage: 30')
const ploon = stringify(obj)
isValid(ploonString)Check if a string is valid PLOON format.
import { isValid } from 'ploon'
if (isValid(input)) {
console.log('Valid PLOON!')
}
validate(ploonString)Get detailed validation results.
import { validate } from 'ploon'
const result = validate(input)
// { valid: boolean, errors?: string[], warnings?: string[] }
const data = {
users: [
{ id: 1, name: 'Alice', email: 'alice@example.com' },
{ id: 2, name: 'Bob', email: 'bob@example.com' }
]
}
const ploon = stringify(data)
// [users#2](email,id,name)
//
// 1:1|alice@example.com|1|Alice
// 1:2|bob@example.com|2|Bob
const data = {
products: [
{
id: 1,
name: 'T-Shirt',
colors: [
{
name: 'Red',
sizes: [
{ size: 'S', stock: 50 },
{ size: 'M', stock: 30 }
]
}
]
}
]
}
const ploon = stringify(data)
// [products#1](colors#(name,sizes#(size,stock)),id,name)
//
// 1:1|1|T-Shirt
// 2:1|Red
// 3:1|S|50
// 3:2|M|30
// CSV-style (comma delimiter, custom path separator)
const csvStyle = stringify(data, {
config: {
fieldDelimiter: ',',
pathSeparator: ':' // Can still use : or customize
}
})
// [products#2](id,name,price)
//
// 1:1,1,Shirt,29.99
// 1:2,2,Pants,49.99
# Convert JSON to PLOON
ploon data.json
# Convert to compact format
ploon data.json --minify
ploon data.json --minify -o output.ploon
# Explicit input format
ploon --from=xml data.xml
ploon --from=yaml data.yaml
# Convert PLOON to JSON
ploon --to=json data.ploon
# Convert PLOON to XML
ploon --to=xml data.ploon -o output.xml
# Format conversion
ploon data.ploon --minify # Standard → Compact
ploon data.ploon --prettify # Compact → Standard
# Validation
ploon data.ploon --validate
# Show statistics
ploon data.json --stats
# Custom delimiters
ploon data.json --field-delimiter="," --path-separator="/"
# Config file
ploon data.json --config=custom.json
-o, --output <file> Output file (default: stdout)
--from <format> Input format: json|xml|yaml (default: auto)
--to <format> Output format: json|xml|yaml (from PLOON)
--minify Output compact format
--prettify Output standard format
--validate Validate PLOON format
--stats Show token comparison
-c, --config <file> Custom configuration file
--field-delimiter <char> Field delimiter (default: |)
--path-separator <char> Path separator (default: :)
--array-marker <char> Array size marker (default: #)
{
fieldDelimiter: '|', // Separates values
pathSeparator: ':', // Separates depth:index (e.g., 5:1)
arraySizeMarker: '#', // Array length marker
recordSeparator: '\n', // Newline (standard) or ';' (compact)
escapeChar: '\\', // Escape special characters
schemaOpen: '[', // Schema opening bracket
schemaClose: ']', // Schema closing bracket
fieldsOpen: '(', // Fields opening paren
fieldsClose: ')', // Fields closing paren
nestedSeparator: '|' // Nested schema separator
}
import { PLOON_STANDARD, PLOON_COMPACT } from 'ploon'
// Standard: newline-separated (human-readable)
stringify(data, { config: PLOON_STANDARD })
// Compact: semicolon-separated (token-optimized)
stringify(data, { config: PLOON_COMPACT })
[root#count](field1,field2|nested#(subfield1,subfield2))
1:1|value1|value2
2:1|subvalue1|subvalue2
[root#count](field1,field2|nested#(subfield1,subfield2));1:1|val1|val2;2:1|sub1|sub2
PLOON uses dual path notation to distinguish arrays from objects:
Arrays use depth:index format:
1:1 - First item at depth 12:1 - First child (depth 2) of item 1:13:1 - First grandchild (depth 3)5:4 - Fourth item at depth 5Objects use depth format (depth + space):
2 - Object at depth 23 - Nested object at depth 34 - Deeply nested object at depth 4Schema Notation:
fieldName#(nestedFields) - e.g., items#(id,name,price)fieldName{nestedFields} - e.g., address{street,city,zip}customer{name,address{city,country{code,name}}}Special characters are escaped with backslash \:
\| - Literal pipe\; - Literal semicolon\: - Literal colon\\ - Literal backslashFrom our examples:
| Example | JSON | PLOON | Savings |
|---|---|---|---|
| Simple (2 products) | 166 chars | 62 chars | 62.7% |
| Nested (8 items, 3 levels) | 565 chars | 313 chars | 44.6% |
Both formats achieve similar token efficiency (40-50% vs JSON), with different strengths:
PLOON Advantages:
TOON Advantages:
Choose PLOON when: You have deep nesting (3+ levels), need path-based queries, or want explicit relationships.
Choose TOON when: You prioritize human readability and have shallow structures.
Check out /examples for more:
basic-usage.js - Simple conversionnested-data.js - Deep nesting (3+ levels)multi-format.js - JSON, XML, YAML inputcustom-config.js - Custom delimitersRun them:
node examples/basic-usage.js
node examples/nested-data.js
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Type check
pnpm typecheck
Full TypeScript support with exported types:
import type {
PloonConfig,
StringifyOptions,
ParseOptions,
ValidationResult,
JsonValue,
JsonObject,
JsonArray
} from 'ploon'
Contributions welcome! Please check our Contributing Guide.
MIT © Ciprian Spiridon
Inspired by TOON Format. PLOON offers an alternative approach using path-based hierarchy instead of indentation, achieving comparable token efficiency with different trade-offs.
Made with ❤️ for LLM optimization
FAQs
Path-Level Object Oriented Notation - The Most Token-Efficient Format for Nested Hierarchical Data
We found that ploon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.