Skip to main content

@magrinj/parse-ingredients

A multi-language recipe ingredient parser with zero dependencies

npm install @magrinj/parse-ingredients

Multi-Language

6 languages built-in: English, French, Spanish, Italian, German, and Portuguese. Extensible locale system for adding more.

Parse + Combine + Pretty

Three complementary functions: parse ingredient strings into structured objects, combine duplicates, and format them back to readable text.

Zero Dependencies

Pure TypeScript, lightweight and fast. No external packages to audit or worry about. Tree-shakeable ESM and CJS builds.

See it in action

English

import parse from '@magrinj/parse-ingredients';

parse('1 1/2 cups of flour');
// {
//   quantity: '1.5',
//   unit: 'cup',
//   ingredient: 'flour',
//   article: 'of',
//   minQty: '1.5',
//   maxQty: '1.5'
// }

French

import parse from '@magrinj/parse-ingredients';
import '@magrinj/parse-ingredients/locale/fr';

parse('2 cuillères à soupe de sucre');
// {
//   quantity: '2',
//   unit: 'cuillère à soupe',
//   ingredient: 'sucre',
//   article: 'de',
//   minQty: '2',
//   maxQty: '2'
// }