Over-engineered 4KB parser for semicolon-separated strings. Ridiculously complex thanks to AI. Zero dependencies, maximum overkill. 🤖
💡 Note: Quotes are automatically added when values contain special characters (=, ;, spaces, commas)
The Key-Value String format provides a human-readable and machine-parseable way to represent structured data in a single line. It is particularly useful for configuration strings, command-line parameters, URL parameters, and data exchange where JSON might be too verbose or complex. While multiline input works, the format is optimized for single-line usage and does not support comments.
A key-value string consists of pairs separated by semicolons:
key1=value1;key2=value2;key3=value3;
The parser supports the following data types:
name=John;title="Senior Developer";age=30;salary=75000.50;
tags=frontend,backend,javascript;scores=95,87,92;optional=;
items=apple,,orange;active=true;config="prod";
Note: Examples show single-line format. Comments are not supported in the actual parser.
npm install key-value-string
// Node.js (CommonJS)
const { parseKeyValueString, toKeyValueString } = require('key-value-string');
// Parse key-value string
const result = parseKeyValueString('name=John;age=30;tags=frontend,backend;');
console.log(result);
// Output: { name: 'John', age: 30, tags: ['frontend', 'backend'] }
// Convert object to key-value string
const kvString = toKeyValueString({ name: 'John', age: 30, active: true });
console.log(kvString);
// Output: name=John;age=30;active=true;
# Parse key-value string to JSON
kvs parse "name=John;age=30;tags=frontend,backend;"
# Convert JSON to key-value string
kvs stringify '{"name":"John","age":30}'
# Validate syntax
kvs validate "name=John;age=30;"
Multiple build formats are provided for different environments:
This parser does not execute code and only processes data. However, applications should validate parsed values before use, especially when processing untrusted input.
Built with love and way too much coffee in a single night of pure vibecoding.