Official JavaScript/TypeScript implementation of the UP (Unified Properties) language parser.
π API Documentation | π§ͺ Test Status | π Specification
Universal Support - Works in browsers, Node.js, Deno, and Bun
- β Full UP Syntax Support - Scalars, blocks, lists, tables, multiline strings
- β
Type Annotations - Parse and preserve type hints (
!int
,!bool
, etc.) - β TypeScript - Full type definitions included
- β Universal - Browser, Node.js, Deno, Bun support
- β ESM + CommonJS - Both module formats supported
- β Well-Tested - Comprehensive test suite
- β Zero Dependencies - No external runtime dependencies
- β Lightweight - Small bundle size
- Node.js 16+ (for Node.js usage)
- Modern browser with ES6+ support (for browser usage)
# npm
npm install @uplang/up
# yarn
yarn add @uplang/up
# pnpm
pnpm add @uplang/up
import { Parser } from '@uplang/up';
const parser = new Parser();
const doc = parser.parse(`
name Alice
age!int 30
config {
debug!bool true
}
`);
// Access values
console.log(doc.get('name')); // 'Alice'
// Iterate nodes
for (const node of doc.nodes) {
console.log(node.key, '=', node.value);
}
import { Parser, Document, Node, Value } from '@uplang/up';
const parser = new Parser();
const doc: Document = parser.parse(input);
const name: string | undefined = doc.getScalar('name');
const config: Map<string, Value> | undefined = doc.getBlock('config');
π For detailed examples and tutorials, see QUICKSTART.md
- QUICKSTART.md - Getting started guide with examples
- DESIGN.md - Architecture and design decisions
- UP Specification - Complete language specification
Parser
- Main parser for converting UP text into documentsDocument
- Parsed document with convenient access methodsNode
- Key-value pair with optional type annotationValue
- Union type for all value types (scalar, block, list, table)
import { Parser } from '@uplang/up';
const parser = new Parser();
// Parse string
const doc = parser.parse(upContent);
// Access values
const name = doc.getScalar('name');
const server = doc.getBlock('server');
const tags = doc.getList('tags');
// Iterate all nodes
for (const node of doc.nodes) {
console.log(node.key, node.type, node.value);
}
See DESIGN.md for complete API documentation and implementation details.
<script type="module">
import { Parser } from 'https://cdn.skypack.dev/@uplang/up';
const parser = new Parser();
const doc = parser.parse(`
title "My Config"
port!int 8080
`);
console.log(doc.getScalar('title'));
</script>
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run in watch mode
npm run test:watch
js/
βββ src/
β βββ parser.ts # Main parser implementation
β βββ types.ts # TypeScript definitions
β βββ document.ts # Document class
β βββ index.ts # Public API exports
βββ dist/
β βββ index.js # CommonJS build
β βββ index.mjs # ESM build
β βββ index.d.ts # TypeScript definitions
βββ test/
β βββ parser.test.ts # Comprehensive tests
βββ package.json
βββ README.md # This file
βββ QUICKSTART.md # Getting started guide
βββ DESIGN.md # Architecture documentation
βββ LICENSE # GNU GPLv3
Contributions are welcome! Please see the main CONTRIBUTING.md for guidelines.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- UP Language Specification - Official language spec
- Syntax Reference - Quick syntax guide
- UP Namespaces - Official namespace plugins
- Go - Reference implementation
- Java - Modern Java 21+ with records and sealed types
- Python - Pythonic implementation with dataclasses
- Rust - Zero-cost abstractions and memory safety
- C - Portable C implementation
- Issues: github.com/uplang/js/issues
- Discussions: github.com/uplang/spec/discussions