NPM Star
Collections
  1. Home
  2. Compare
  3. toml vs yaml
NPM Compare

Compare NPM packages statistics, trends, and features

CollectionsVS Code extensionChrome extensionTermsPrivacyLinkTreeIndiehackersBig Frontendqiuyumi

TOML vs YAML: Configuration File Format Parsers

Both packages help developers read and write configuration files in different formats. TOML and YAML are popular formats for storing settings and configuration data, similar to JSON but with different syntax styles. These packages allow you to convert these configuration files into JavaScript objects that your code can use, making it easier to manage application settings.

Configuration Parsersconfigurationparserfile formatsettingsdata

Unable to load comparison data. Please try again later.

Similar Packages

js-yaml

100%

A very popular JavaScript package that lets you read and write YAML files. It's fast, easy to use, and supports all major YAML features like nested objects and arrays.

This is the most widely used YAML parser in the JavaScript ecosystem. It's battle-tested, well-documented, and used by major frameworks like Vue and Next.js

Data Format Parser

@iarna/toml

100%

A complete TOML parser and writer that fully supports the TOML spec. It makes working with TOML files as simple as working with JSON.

This is considered the best TOML parser for JavaScript. It's actively maintained and has excellent TypeScript support

Data Format Parser

yaml-loader

80%

A webpack loader that helps you import YAML files directly into your JavaScript code. Perfect for when you're working with webpack-based projects.

Great for projects that use webpack and need to work with YAML files, especially in React or Vue applications

Build Tool Integration

json5

70%

A package that adds useful features to JSON like comments, trailing commas, and single quotes. It's like JSON but more friendly for humans to write.

While not YAML or TOML, it's a great alternative when you want something simpler than YAML but more flexible than JSON

Data Format Parser

parse-json

60%

A simple package that makes parsing JSON safer and provides better error messages. It's like JSON.parse but with better error handling.

While it's for JSON, it's often used alongside YAML and TOML parsers when working with different config file formats

Data Format Parser

TOML Parser for Node.js

Build Status

NPM

If you haven't heard of TOML, well you're just missing out. Go check it out now. Back? Good.

TOML Spec Support

toml-node supports version 0.4.0 the TOML spec as specified by mojombo/toml@v0.4.0

Installation

toml-node is available via npm.

npm install toml

toml-node also works with browser module bundlers like Browserify and webpack.

Usage

Standalone

Say you have some awesome TOML in a variable called someTomlString. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.

var toml = require('toml'); var data = toml.parse(someTomlString); console.dir(data);

toml.parse throws an exception in the case of a parsing error; such exceptions have a line and column property on them to help identify the offending text.

try { toml.parse(someCrazyKnuckleHeadedTrblToml); } catch (e) { console.error("Parsing error on line " + e.line + ", column " + e.column + ": " + e.message); }

Streaming

As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like concat-stream:

var toml = require('toml'); var concat = require('concat-stream'); var fs = require('fs'); fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) { var parsed = toml.parse(data); }));

Thanks @ForbesLindesay for the suggestion.

Requiring with Node.js

You can use the toml-require package to require() your .toml files with Node.js

Live Demo

You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.

Building & Testing

toml-node uses the PEG.js parser generator.

npm install
npm run build
npm test

Any changes to src/toml.peg requires a regeneration of the parser with npm run build.

toml-node is tested on Travis CI and is tested against:

  • Node 0.10
  • Node 0.12
  • Latest stable io.js

License

toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.

No README available

Dependencies Comparison

toml

Dependencies

Dev Dependencies

jshint*
nodeunit~0.9.0
pegjs~0.8.0

Peer Dependencies

yaml

Dependencies

Dev Dependencies

jest^29.0.1
tslib^2.8.1
eslint^9.9.1
rollup^4.12.0
prettier^3.0.2
@eslint/js^9.9.1
babel-jest^29.0.1
fast-check^2.12.0
typescript^5.7.2
@babel/core^7.12.10
@types/jest^29.2.4
@types/node^20.11.20
jest-resolve^29.7.0
@babel/preset-env^7.12.11
typescript-eslint^8.4.0
@rollup/plugin-babel^6.0.3
@rollup/plugin-replace^6.0.3
eslint-config-prettier^10.1.8
@rollup/plugin-typescript^12.1.1
jest-ts-webcompat-resolver^1.0.0
@babel/plugin-transform-typescript^7.12.17

Peer Dependencies

StarsIssuesVersionUpdatedⓘLast publish dateCreatedⓘPackage creation dateSizeⓘMinified + Gzipped size
T
toml
315223.0.03 years ago13 years agoinstall size N/A
Y
yaml
1,617262.8.2a month ago15 years agoinstall size N/A

Who's Using These Packages

toml

sile
sile

The SILE Typesetter — Simon’s Improved Layout Engine

CYFS
CYFS

CYFS is the next-generation technology to build real Web3 by upgrading the basic protocol of Web (TCP/IP+DNS+HTTP),is short for CYberFileSystem. https://www.cyfs.com/, cyfs://cyfs/index_en.html.

Dependency
Dependency

Dependency 🖇️

eslint-online-playground
eslint-online-playground

ESLint Online Playground

ccjk
ccjk

🚀 CCJK In the realm of AI-assisted development, Context Engineering and Cognitive Load Management are the decisive factors for development efficiency. CCJK is built on this insight, delivering the industry's first Cognitive Enhancement Engine.

yaml

obsidian-tasks
obsidian-tasks

Task management for the Obsidian knowledge base.

fabrica-dev-kit
fabrica-dev-kit

A toolkit for faster, smoother WordPress 5 development

rails-templates
rails-templates

Our optimized Rails templates used in our projects

pola-web
pola-web

Pola pomoże Ci odnaleźć polskie wyroby. Zabierając Polę na zakupy odnajdujesz produkty “z duszą” i wspierasz polską gospodarkę.

sonarqube-webapp
sonarqube-webapp

SonarQube Community Build Web App