Getting Started with Molt โ
Welcome to Molt, the high-performance data transformation stack! This guide will help you understand what Molt is and why you should use it.
What is Molt? โ
Molt is a comprehensive suite of data transformation libraries built for performance and developer experience. Each package in the Molt ecosystem is designed to handle a specific data format with extreme efficiency and type safety.
Available Packages โ
- @sylphx/molt-json - Type-preserving JSON parser and serializer
- @sylphx/molt-yaml - Ultra-fast YAML processor
- @sylphx/molt-toml - High-performance TOML parser
- @sylphx/molt-ini - Fast INI configuration parser
- @sylphx/molt-csv - Blazingly fast CSV handler
- @sylphx/molt-xml - Competitive XML parser with dirty input support
- @sylphx/molt-msgpack - Binary MessagePack encoder/decoder
- @sylphx/molt-toon - LLM-optimized Token-Oriented Object Notation
Why Choose Molt? โ
๐ Exceptional Performance โ
Molt consistently outperforms industry-standard libraries across all formats:
| Format | Performance | vs Competition |
|---|---|---|
| YAML | 1,021,050 ops/s | 2.87x faster than js-yaml |
| TOML | 892,620 ops/s | 2.07x faster than @iarna/toml |
| JSON | 610,000 ops/s | 1.7x faster serialization |
| INI | High | 2-3x faster than ini (npm) |
| CSV | 775,770 ops/s | 5.9x faster than papaparse |
| XML | 102,975 ops/s | Matches fast-xml-parser |
| MessagePack | Competitive | Comparable to @msgpack/msgpack |
| TOON | N/A | 30-60% fewer tokens for LLMs |
See Benchmarks for detailed comparisons.
๐ก๏ธ Type Safety โ
JavaScript types like Date, BigInt, Map, Set, and RegExp are automatically preserved through serialization with molt-json:
const data = {
created: new Date(),
id: 123456789012345678901n,
tags: new Set(['a', 'b', 'c']),
config: new Map([['key', 'value']])
}
const json = molt.stringify(data)
const restored = molt(json)
restored.created instanceof Date // true
restored.id === 123456789012345678901n // true
restored.tags instanceof Set // true๐งน Dirty Input Support โ
Real-world data is messy. Molt handles it gracefully:
// JavaScript-style comments
const data = molt(`{
// This is a comment
name: 'Alice', // Unquoted key
email: 'alice@test.com', // Single quotes
tags: [1, 2, 3,], // Trailing comma
}`)๐ฆ Zero Dependencies โ
All Molt packages are production-grade with zero external dependencies. Pure TypeScript with optional Rust/WASM acceleration for compute-intensive operations.
โก Ready for Production โ
- 120+ test cases per package
- Streaming support for large files
- Schema validation (Zod, JSON Schema compatible)
- Comprehensive error messages
- Type-safe TypeScript APIs
Quick Installation โ
Using npm โ
npm install @sylphx/molt-jsonUsing pnpm โ
pnpm add @sylphx/molt-jsonUsing Bun โ
bun add @sylphx/molt-jsonReplace molt-json with your desired package: molt-yaml, molt-toml, molt-csv, or molt-xml.
Basic Usage Examples โ
JSON โ
import { molt, stringify } from '@sylphx/molt-json'
// Parse dirty JSON
const data = molt('{ name: "Alice", age: 30 }')
// Stringify with type preservation
const json = stringify({ created: new Date() })YAML โ
import { parse, stringify } from '@sylphx/molt-yaml'
const config = parse(`
database:
host: localhost
port: 5432
`)
console.log(stringify(config))TOML โ
import { parse, stringify } from '@sylphx/molt-toml'
const config = parse(`
[package]
name = "my-app"
version = "1.0.0"
`)CSV โ
import { parse, stringify } from '@sylphx/molt-csv'
const records = parse('name,age\nAlice,30')
console.log(stringify(records))XML โ
import { parse, toObject } from '@sylphx/molt-xml'
const doc = parse('<root><item>value</item></root>')
const obj = toObject(doc)INI โ
import { molt } from '@sylphx/molt-ini'
const config = molt(`
[database]
host = localhost
port = 5432
`)MessagePack โ
import { encode, decode } from '@sylphx/molt-msgpack'
const binary = encode({ user: 'alice' })
const data = decode(binary)TOON โ
import { parseTOON, serializeTOON } from '@sylphx/molt-toon'
// Parse TOON format
const data = parseTOON(`
users:
id | name | age
1 | Alice | 30
2 | Bob | 25
`)
// Serialize to TOON (30-60% fewer tokens)
const toon = serializeTOON(data)Next Steps โ
- Installation Guide - Detailed setup for each package
- Quick Start Examples - More comprehensive examples
- Benchmarks - Performance comparison details
- Package Documentation - Deep dive into each package's features
Need Help? โ
- Check the Frequently Asked Questions below
- Visit the GitHub Issues
- Start a Discussion
FAQ โ
Q: Which package should I choose? โ
A: Choose based on your data format:
- JSON data โ
molt-json - YAML config โ
molt-yaml - TOML settings โ
molt-toml - CSV data โ
molt-csv - XML documents โ
molt-xml
Q: Does Molt require special setup? โ
A: No! Just install the package and start using it. Zero configuration needed.
Q: Are types truly preserved in molt-json? โ
A: Yes! Date, BigInt, Map, Set, RegExp, Uint8Array, and more are automatically preserved through stringify/parse cycles.
Q: How much faster is Molt really? โ
A: Significantly faster in most cases. YAML is 2-415x faster, TOML is 2-9x faster, JSON serialization is 1.7-2.3x faster. See benchmarks for details.
Q: Is this production-ready? โ
A: Absolutely. Molt is used in production applications with 120+ tests per package and zero external dependencies.
Ready to get started? Check out the Installation Guide next!