{"id":31447355,"url":"https://github.com/komed3/chemparse","last_synced_at":"2026-01-20T17:00:46.249Z","repository":{"id":316324059,"uuid":"1062899642","full_name":"komed3/chemparse","owner":"komed3","description":"TypeScript library for parsing chemical formulas. Supports nested parentheses, decimal and scientific notation, dot-separated hydrate parts, and strict validation of IUPAC element symbols.","archived":false,"fork":false,"pushed_at":"2025-09-26T11:27:31.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-01T01:23:17.354Z","etag":null,"topics":["chemistry","chemistry-formulas","formula-parser","npm-package"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/chemparse","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/komed3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T22:21:33.000Z","updated_at":"2025-09-26T11:27:35.000Z","dependencies_parsed_at":"2025-09-24T00:24:37.472Z","dependency_job_id":"e106d713-1c42-45fd-8589-b8fab2fbefe4","html_url":"https://github.com/komed3/chemparse","commit_stats":null,"previous_names":["komed3/chemparse"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/komed3/chemparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Fchemparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Fchemparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Fchemparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Fchemparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/komed3","download_url":"https://codeload.github.com/komed3/chemparse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Fchemparse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chemistry","chemistry-formulas","formula-parser","npm-package"],"created_at":"2025-10-01T01:16:52.177Z","updated_at":"2026-01-20T17:00:46.240Z","avatar_url":"https://github.com/komed3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChemParse\n\n**ChemParse** is a lightweight TypeScript library for parsing chemical formulas.\n\nIt supports nested parentheses, decimal and scientific notation, dot-separated hydrate parts, ionic charges, and strict validation of IUPAC element symbols.\n\n## Features\n\n- Parses chemical formulas into element counts\n- Handles hydrates and dot-separated parts (e.g., `CuSO4·5H2O`, `CCl3_CH(OH)2`)\n- Supports nested parentheses/brackets (e.g., `K4[Fe(CN)6]`)\n- Accepts decimal and scientific notation (e.g., `C1.5O3`, `H2e-1O1e-1`)\n- Handles ionic charges (e.g., `SO4^2-`, `NH4^+`)\n- Strict validation against all 118 IUPAC element symbols\n- TypeScript types included\n\n## Installation\n\n```bash\nnpm install chemparse\n```\n\n## Usage\n\nNode.js (CommonJS)\n\n```js\nconst ChemParse = require( 'chemparse' ).default;\n\nconst result = ChemParse.parse( 'CuSO4·5H2O' );\nconsole.log( result );\n// { elementCounts: { H: 10, O: 9, S: 1, Cu: 1 } }\n```\n\nNode.js (ESM / TypeScript)\n\n```js\nimport ChemParse from 'chemparse';\n\nconst result = ChemParse.parse( 'K4[Fe(CN)6]' );\nconsole.log( result );\n// { elementCounts: { C: 6, N: 6, K: 4, Fe: 1 } }\n```\n\nThe package can also be used in browser environments.  \nTo do so, simply load the script as UMD or ESM from jsDelivr:  \nhttps://jsdelivr.com/package/npm/chemparse\n\n```html\n\u003cscript type=\"module\"\u003e\n  import ChemParse from 'https://cdn.jsdelivr.net/npm/chemparse@1.0.1/+esm'\n\n  const result = ChemParse.parse( 'CH3COO^-' );\n  console.log( result );\n  // { elementCounts: { H: 3, C: 2, O: 2 }, charge: -1 }\n\u003c/script\u003e\n```\n\n## API\n\n**`ChemParse.parse ( formula: string ) : ChemParseResult`**  \nPases a chemical formula and returns an object mapping element symbols to their counts and optional charge.\n\n**`ChemParse.validate ( formula: string ) : boolean`**  \nReturns `true` if the formula is valid, otherwise `false`.\n\n**`ChemParse.compare ( a: string, b: string ) : boolean`**  \nReturns `true` if both formulas represent the same element distribution.\n\n**`ChemParse.diff ( a: string, b: string ) : ChemParseResult`**  \nReturns the difference in element counts and ionic charge between two formulas (`a - b`).\n\n## Supported Formula Syntax\n\n- Simple formulas: `H2O`, `NaMnO4`, `C6H12O6`\n- Hydrates and dot notation: `CuSO4·5H2O`, `CCl3_CH(OH)2`, `2.5H2O`, `.5H2O`\n- Parentheses and nested groups: `Ca(OH)2`, `(NH4)2SO4`, `K4[Fe(CN)6]`, `Al2(SO4)3`\n- Decimal and scientific notation: `C1.5O3`, `H2e-1O1e-1`, `Mg(OH)1.5`, `Fe2(SO4)1.5`\n- Element lists with commas: `Fe2(S,O4)`, `Al2(S,O4)3`\n- Leading coefficients: `2H2O`, `5·H2O`\n- Ionic charges: `SO4^2-`, `NH4^+`, `CH3COO^-`, `Fe(CN)6^3-`\n\n## Example\n\n```js\nimport ChemParse from 'chemparse';\n\nChemParse.parse( 'CuSO4·5H2O' );\n// =\u003e { elementCounts: { H: 10, O: 9, S: 1, Cu: 1 } }\n\nChemParse.parse( 'K4[Fe(CN)6]' );\n// =\u003e { elementCounts: { C: 6, N: 6, K: 4, Fe: 1 } }\n\nChemParse.parse( 'C1.5O3' );\n// =\u003e { elementCounts: { C: 1.5, O: 1 } }\n\nChemParse.parse( 'H2e-1O1e-1' );\n// =\u003e { elementCounts: { H: 0.2, O: 0.1 } }\n\nChemParse.parse( 'CH3COO^-' );\n// =\u003e { elementCounts: { H: 3, C: 2, O: 2 }, charge: -1 }\n\nChemParse.parse( 'Fe(CN)6^3-' );\n// =\u003e { elementCounts: { C: 6, N: 6, Fe: 1 }, charge: -3 }\n\nChemParse.parse( 'Al2(S,O4)3' );\n// =\u003e { elementCounts: { O: 12, Al: 2, S: 3 } }\n\nChemParse.validate( 'Fe2(SO4)1.5' );\n// =\u003e true\n\nChemParse.compare( 'H2O', 'OH2' );\n// =\u003e true\n\nChemParse.diff( 'C6H12O6', 'C1.5O3' );\n// =\u003e { elementCounts: { H: 12, C: 4.5, O: 0 } }\n```\n\n## License\n\nMIT © Paul Köhler (komed3)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Fchemparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkomed3%2Fchemparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Fchemparse/lists"}