yini-parser
TypeScript icon, indicating that this package has built-in type declarations

1.2.0-beta • Public • Published

YINI Parser for Node.js

A TypeScript/Node.js parser for YINI — A type-safe, structured, and human-readable config format with nested sections, types, comments, and support for strict validation.

npm version All Tests

npm install yini-parser
import YINI from 'yini-parser'
const config = YINI.parseFile('./config.yini')

YINI (Yet another INI): YINI is a configuration format designed for readability and structure, inspired by INI and YAML.

➡️ See full documentation or YINI format specification

Enjoying YINI? If you find this project useful, please consider starring it on GitHub — it helps others discover it!


YINI Parser – (source code in TypeScript)

🚧 This package is in beta. The core API is stabilizing, some more advanced features may still change. Feedback and bug reports are welcome!

YINI Parser in TypeScript — a runtime library for Node.js.
A parser / reader for the YINI configuration file format.

This library implements the official YINI specification using TypeScript + ANTLR4.

YINI is a simple, human-friendly configuration format inspired by INI and JSON.


🙋‍♀️ Why YINI?

  • YINI is an alternative to other great config formats like INI, JSON, YAML, XML, and TOML — Supports section nesting and explicit syntax for configuration files.
  • Started as a personal project and a research challenge: Provides structure similar to INI, with features inspired by JSON and YAML.
  • Built for clarity:
    • Uses a concise syntax to minimize unnecessary characters.
    • Supports commonly used configuration structures.
  • *Developed to meet practical needs, driven by curiosity and a desire for configuration clarity, simplicity, minimalism, and flexibility.

💡 What is YINI?

  • Simple like INI — but with strong typing, comments, and nested sections.
  • Provides concise, structured syntax for configuration.
  • Supports section nesting without requiring indentation or dot-delimited keys.
  • This repo/parser is built for both JavaScript and TypeScript.
  • Supports strict and lenient modes, and all major data types.
  • Can be edited manually or processed programmatically.
  • 👉 See how YINI compares with JSON, YAML, INI, and TOML.
  • Want the full syntax reference? See the YINI Specification.

Quick Start

A small example using YINI in TypeScript/JavaScript:

import YINI from 'yini-parser'

const config = YINI.parse(`
    // YINI is a simple, human-readable configuration file format.

    // Note: In YINI, spaces and tabs don't change meaning - 
    // indentation is just for readability.

    ^ App                      // Definition of section (group) "App" 
      name     = 'My Title'    // Keys and values are written as key = value
      items    = 25
      darkMode = true          // "ON" and "YES" works too

        // Sub-section of the "App" section
        ^^ Special
           primaryColor = #336699   // Hex number format
           isCaching    = false     // "OFF" and "NO" works too
`)

// To parse from a file instead:
// const config = YINI.parseFile('./config.yini')

console.log(config.App.name)                // My Title
console.log(config.App.Special.isCaching)   // false
console.log()
console.log(config)

Output:

My Title
false

{
    App: {
        name: 'My Title',
        items: 25,
        darkMode: true,
        Special: { 
            primaryColor: 3368601,
            isCaching: false
        }
    }
}

That's it!


Intro to YINI Config Format

YINI is a simple and readable configuration format. Sections are defined with ^ SectionName, and values are assigned using key = value. The format supports common data types (same as those found in JSON), including strings, numbers, booleans, nulls, and lists.

To learn more, see the Getting Started: Intro to YINI Config Format tutorial.


Usage

Installation

With npm:

npm install yini-parser

With yarn:

yarn add yini-parser

With pnpm:

pnpm add yini-parser

Node.js (CommonJS)

Note: Only a default export (YINI) is provided. Named imports are not supported.

const YINI = require('yini-parser').default;
// (!) If you get undefined, try:
// (Some Node.js setups require the .default property, others don't, due to ESM/CommonJS interop quirks.)
const YINI = require('yini-parser');

// Parse from string.
const config = YINI.parse(`
    ^ App
    title = 'My App Title'
    items = 25
    isDarkTheme = true
`);

// Parse from file.
const configFromFile = YINI.parseFile('./config.yini');

TypeScript (with "esModuleInterop": true)

import YINI from 'yini-parser';

// Parse from string.
const config = YINI.parse(`
    ^ App
    title = "My App Title"
    items = 25
    isDarkTheme = OFF
`);

// Parse from file.
const configFromFile = YINI.parseFile('./config.yini');

Example Output

// JS object
{
   App: {
      title: "My App Title",
      items: 25,
      isDarkTheme: false
   }
}

✨ Features

  • Simple syntax (supports both strict and lenient modes).
  • Familiar config file style (inspired by INI, JSON, Python, and Markdown).
  • Easy programmatic usage.
  • Only the YINI class is exported; all internal details are private.
  • Lists (bracketed): list = [10, 20, 30]
  • 🚧 (Planned – not yet implemented in parser) Supports alternative list notation (colon‑style lists):
    fruits:
        'Pear',
        'Cherry',
        'Banana'
    

Limitations

Not all features of the full YINI are implemented yet.

See FEATURE-CHECKLIST.md for the current list of implemented YINI features.

🚧 Missing or Upcoming Features

This parser currently supports all core YINI syntax for values, comments, section headers, and basic nesting.

The following features from the YINI specification are planned but not yet fully implemented:

  • Object literals
  • Advanced escape sequences
  • String types and triple-quoted strings
  • All number format literals
  • Full strict mode validation

You can follow progress in the YINI parser GitHub repo-FEATURE-CHECKLIST. Contributions and feature requests are welcome!

📂 Examples

See the examples/ folder for:

  • Basic YINI file with common types and comments
  • Nested sections example
  • Comparison with JSON/YAML config

These examples are also included in the npm package.


Bigger Example

const YINI = require('yini-parser').default; // Or: import YINI from 'yini-parser';

const config = YINI.parse(`
    // This is a comment in YINI
    // YINI is a simple, human-readable configuration file format.

    // Note: In YINI, spaces and tabs don't change meaning - indentation is just
    // for readability.

    /*  This is a block comment

        In YINI, section headers use repeated characters "^" at the start to
        show their level: (Section header names are case-sensitive.)

        ^ SectionLevel1
        ^^ SectionLevel2
        ^^^ SectionLevel3
    */

    ^ App                           // Definition of section (group) "App" 
      title = 'My App'
      items = 25
      debug = ON                    // "true" and "YES" works too

    ^ Server                        // Definition of section (group) "Server"
      host = 'localhost'
      port = 8080
      useTLS = OFF                  // "false" and "NO" works too

        // Sub-section of "Server"
        ^^ Login
          username = 'user_name'
          password = 'your_password_here'
    
    /END // (only optional)
`);

console.log(config);

Output:

// JS object
{
    App: {
        title: 'My App', 
        items: 25, 
        debug: true
    },
    Server: {
        host: 'localhost',
        port: 8080,
        useTLS: false,
        Login: { 
            username: 'user_name', 
            password: 'your_password_here'
        }
    }
}

Output in JSON:

{
    "App": {
        "title": "My App",
        "items": 25,
        "debug": true
    },
    "Server": {
        "host": "localhost",
        "port": 8080,
        "useTLS": false,
        "Login": {
            "username": "user_name",
            "password": "your_password_here"
        }
    }
}

🤝 Contributing

We welcome feedback, bug reports, feature requests, and code contributions!


📚 Documentation


Links


License

This project is licensed under the Apache-2.0 license - see the LICENSE file for details.

In this project on GitHub, the libs directory contains third party software and each is licensed under its own license which is described in its own license file under the respective directory under libs.


~ YINI ≡https://yini-lang.org

Package Sidebar

Install

npm i yini-parser

Weekly Downloads

79

Version

1.2.0-beta

License

Apache-2.0

Unpacked Size

670 kB

Total Files

107

Last publish

Collaborators

  • mr_smithnen