{"library":"properties-file","title":"properties-file parser & editor","description":"The `properties-file` library provides a high-performance, lossless parser, editor, and formatter for Java-style `.properties` files. Currently stable at version 5.0.4, it undergoes active maintenance with frequent releases (multiple patches per month based on recent history). A key differentiator is its lossless data model, preserving comments, blank lines, and duplicate keys, allowing for exact reconstruction or normalized output via `format()` options. It boasts 3–7x faster parsing than alternatives, zero dependencies, and a tiny bundle size (970 B min+gzip for `getProperties`). Compiled to ES5, it offers broad compatibility, running on Node.js versions back to 0.4.0 and any modern browser. It also includes bundler integrations for Webpack, Rollup/Vite, esbuild, and Bun to import `.properties` files directly.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install properties-file"],"cli":null},"imports":["import { getProperties } from 'properties-file'","import { Properties } from 'properties-file/parser'","import { PropertiesEditor } from 'properties-file/editor'","import 'properties-file/bundler/webpack'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { readFileSync } from 'node:fs';\nimport { getProperties, Properties, PropertiesNodeType } from 'properties-file/parser';\nimport { PropertiesEditor } from 'properties-file/editor';\n\n// Example .properties content\nconst fileContent = `\n# This is a comment\nhello=world\nfoo:bar\\n\\r\nkey.with.escapes=value with spaces and \\\\ backslashes\nduplicate=first\nduplicate=second\n`;\n\n// 1. Basic key-value parsing\nconst simpleObject = getProperties(fileContent);\nconsole.log('Simple object:', simpleObject);\n// Expected: { hello: 'world', 'foo:bar': '', 'key.with.escapes': 'value with spaces and \\ backslashes', duplicate: 'second' }\n\n// 2. Lossless parsing with full data model\nconst properties = new Properties(fileContent);\nconsole.log('\\nLossless Nodes:');\nfor (const node of properties.nodes) {\n  switch (node.type) {\n    case PropertiesNodeType.PROPERTY:\n      console.log(`PROPERTY: ${node.key} = ${node.value}`);\n      break;\n    case PropertiesNodeType.COMMENT:\n      console.log(`COMMENT: ${node.body}`);\n      break;\n    case PropertiesNodeType.BLANK:\n      console.log('BLANK LINE');\n      break;\n  }\n}\n\n// 3. Editing properties\nconst editor = new PropertiesEditor(fileContent);\neditor.upsert('new_key', 'new_value');\neditor.delete('duplicate', { occurrence: 'first' }); // Delete the first 'duplicate'\neditor.update('hello', 'updated_world');\n\nconsole.log('\\nEdited properties:');\nconsole.log(editor.format());\n","lang":"typescript","description":"This quickstart demonstrates the core functionalities: `getProperties` for simple key-value extraction, `Properties` for lossless parsing and node inspection, and `PropertiesEditor` for modifying entries while preserving formatting.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}