CREB-JS Documentation
Advanced Chemical Reaction Equation Balancer with PubChem Integration
๐งช What is CREB-JS?
CREB-JS is a comprehensive JavaScript library that revolutionizes chemical equation balancing and stoichiometric calculations. Built with modern TypeScript, it combines robust equation parsing algorithms with real-world chemical data from the PubChem database to provide accurate, validated chemical computations.
Whether you're a student learning chemistry, a researcher performing calculations, or a developer building chemical informatics applications, CREB-JS provides the tools you need with a simple, intuitive API.
๐ Quick Start
Get started with CREB-JS in just a few lines of code:
โจ Key Features
โ๏ธ Smart Equation Balancing
Advanced algorithms automatically balance even complex chemical equations with robust error handling and validation.
๐งฎ Stoichiometric Calculations
Calculate molar relationships, limiting reagents, theoretical yields, and percent yields with precision.
๐ PubChem Integration
Access real chemical data including molecular weights, formulas, properties, and structural information.
๐ Compound Comparison
Compare multiple compounds side-by-side with detailed property analysis and structural similarities.
โ Data Validation
Cross-reference calculated results with PubChem data to ensure accuracy and catch potential errors.
๐ Universal Compatibility
Works in browsers, Node.js, and modern frameworks with TypeScript support and multiple output formats.
๐ฏ Use Cases
- Educational Tools: Interactive chemistry learning platforms and homework helpers
- Research Applications: Laboratory calculations and chemical analysis workflows
- Industrial Software: Chemical process optimization and quality control systems
- Web Applications: Chemistry calculators and molecular property databases
- Academic Research: Computational chemistry and cheminformatics projects
๐ Documentation Structure
This documentation is organized into several sections to help you get the most out of CREB-JS:
- Getting Started: Installation, setup, and basic usage patterns
- Balancing Equations: Comprehensive guide to equation balancing features
- Stoichiometry: Advanced calculations and molar relationships
- PubChem Integration: Accessing and using real chemical data
- API Reference: Complete method documentation and parameters
- Examples: Practical code samples and common patterns
๐ Getting Started
Complete setup guide and first steps with CREB-JS
๐ฆ Installation
CREB-JS is distributed as npm packages. Choose the installation method that works best for your project:
Install Core Package
For basic equation balancing and stoichiometry calculations:
Add PubChem Integration (Optional)
For enhanced features with real chemical data:
Browser Usage
For direct browser usage, include the UMD builds:
โก Quick Setup
Get up and running with CREB-JS in minutes:
๐งช Your First Equation
Let's balance your first chemical equation with the interactive demo below:
โ๏ธ Chemical Equation Balancer
Enter an unbalanced chemical equation and get the balanced version instantly.
๐ Learning Path
Follow this recommended learning path to master CREB-JS:
1๏ธโฃ Basic Balancing
Start with simple equation balancing to understand the core functionality and API.
โ Learn Balancing2๏ธโฃ Stoichiometry
Learn to calculate molar relationships, limiting reagents, and yields.
โ Learn Stoichiometry3๏ธโฃ PubChem Data
Enhance your calculations with real chemical data from PubChem.
โ Learn PubChem4๏ธโฃ Advanced Features
Explore compound comparison, validation, and enhanced calculations.
โ Advanced Features๐ง Configuration
CREB-JS works out of the box with sensible defaults, but you can customize its behavior:
โ Need Help?
If you encounter any issues or have questions:
- Check the API Documentation for detailed method information
- Browse Code Examples for common usage patterns
- Visit our GitHub Issues to report bugs or request features
- Read the README for additional setup information
Balancing equations
Advanced equation balancing features
CREB-JS uses matrix algebra to solve systems of linear equations, ensuring accurate balancing of even complex chemical equations.
โ๏ธ Advanced Equation Balancing
Try complex equations with multiple reactants and products:
How it works
The balancing algorithm:
- Parses the chemical equation to extract reactants and products
- Creates a matrix of element coefficients
- Solves the system using Gaussian elimination
- Returns the smallest integer coefficients
Stoichiometry
Calculate molar relationships and conversions
Perform stoichiometric calculations to determine the quantities of reactants and products in chemical reactions.
๐ Stoichiometric Calculator
Calculate molar relationships from a balanced equation:
โ๏ธ Molar Weight Calculator
Calculate the molar weight of any chemical formula:
Compound search
Search PubChem database for chemical compounds
CREB-JS integrates with the PubChem database to provide access to millions of chemical compounds and their properties.
๐ Search by PubChem CID
Enter a PubChem Compound ID to retrieve detailed compound information:
๐งช Formula Search
Search for compounds by molecular formula using PubChem's comprehensive database
๐ Search by Molecular Formula
Enter a molecular formula to find all compounds with that exact formula. This is useful for finding isomers and exploring chemical diversity.
Formula Search Demo
๐ก Common Formula Examples
Try these common molecular formulas to explore different types of compounds:
HโO
Water and related compounds
CโHโโOโ
Glucose and sugar isomers
CโHโOโ
Aspirin and related compounds
CโHโโNโOโ
Caffeine and similar stimulants
CโHโO
Ethanol and ether isomers
CHโ
Methane and simple hydrocarbons
๐ Formula Search Features
๐ Comprehensive Search
Search PubChem's database of millions of compounds by exact molecular formula match.
โก Fast Results
Optimized search returns up to 100 results quickly, perfect for exploring chemical space.
๐งฌ Isomer Discovery
Find all structural isomers that share the same molecular formula but different arrangements.
๐ Rich Data
Each result includes CID, molecular weight, IUPAC names, and other chemical properties.
๐ป Formula Search API
Use formula search in your applications with these simple methods:
๐งช Enhanced Chemical Intelligence
Advanced equation balancing with real-world compound data from PubChem
๐ PubChem-Enhanced Balancing
Balance equations and get comprehensive compound information including molecular weights, IUPAC names, and validation from the authoritative PubChem database.
Enhanced Balancing Demo
๐ก Example Equations
Try these common chemical reactions to see enhanced balancing in action:
Acid-Base Neutralization
Sulfuric acid + Sodium hydroxide
Glucose Combustion
Cellular respiration reaction
Limestone Dissolution
Calcium carbonate + Hydrochloric acid
Iron Oxidation
Rust formation reaction
Ammonia Reaction
Ammonium chloride formation
Methane Combustion
Natural gas burning
๐ Enhanced Intelligence Features
๐ฏ Real Molecular Weights
Get precise molecular weights from PubChem instead of calculated approximations.
๐ท๏ธ IUPAC Names
See standardized chemical names alongside molecular formulas for better understanding.
โ Mass Balance Validation
Automatic verification that mass is conserved using real molecular weight data.
๐ Compound Validation
Verify that all compounds in your equation exist and are correctly identified.
๐ป Enhanced Intelligence API
Access enhanced chemical intelligence in your applications:
๐ท๏ธ Compound Name Resolution
Balance equations using common chemical names instead of formulas
๐ Balance by Common Names
Enter equations using everyday chemical names like "water", "sulfuric acid", or "sodium hydroxide". CREB-JS will automatically resolve these names to their chemical formulas using PubChem and then balance the equation.
Name Resolution Demo
๐ก Common Name Examples
Try these equations using common chemical names:
Acid-Base Reaction
Using common acid/base names
Gas Absorption
HCl gas + ammonia reaction
Cellular Respiration
Using biochemical names
Natural Gas Combustion
Common fuel burning
Limestone Reaction
Geological chemistry
Alcohol Combustion
Ethyl alcohol burning
๐ Name Resolution Features
๐ง Intelligent Parsing
Automatically identifies and separates compound names from the equation structure.
๐ท๏ธ Name Standardization
Handles variations like "sulfuric acid" vs "sulphuric acid" automatically.
๐ PubChem Resolution
Resolves names to chemical formulas using PubChem's comprehensive database.
๐ Name Mapping
Maintains mapping between original names and resolved formulas for transparency.
๐ป Name Resolution API
Use name resolution in your applications:
โ๏ธ Enhanced Stoichiometry
Precise stoichiometric calculations using real molecular weights from PubChem
๐ PubChem-Powered Calculations
Perform stoichiometric calculations with unprecedented accuracy using real molecular weights from the PubChem database. Compare calculated vs. real molecular weights and get precision assessments.
Enhanced Stoichiometry Demo
๐ก Example Calculations
Try these stoichiometry problems with enhanced accuracy:
Silver Chloride Precipitation
0.171 mol NaCl โ ? g AgCl
Glucose Respiration
1.0 mol glucose โ ? g COโ
Water Formation
2.0 mol Hโ โ ? g HโO
Limestone Dissolution
0.5 mol CaCOโ โ ? g COโ
Iron Chloride Formation
1.5 mol Fe โ ? g FeClโ
Methane Combustion
0.75 mol CHโ โ ? g HโO
๐ Enhanced Stoichiometry Features
๐ฏ Real Molecular Weights
Use precise molecular weights from PubChem instead of calculated approximations.
๐ Accuracy Analysis
Compare calculated vs. real molecular weights and assess precision levels.
โ Mass Balance Validation
Verify conservation of mass using real molecular weight data.
๐ Compound Validation
Ensure all compounds exist and are correctly identified before calculations.
๐ป Enhanced Stoichiometry API
Perform enhanced calculations in your applications:
โ ๏ธ Chemical Safety Information
Comprehensive safety warnings and hazard classifications for chemical reactions
๐ก๏ธ GHS Safety Integration
Get comprehensive safety information including GHS hazard classifications, signal words, and precautionary statements for all compounds in your chemical equations.
Safety Analysis Demo
๐ก Example Safety Analyses
See safety information for these common chemical reactions:
Strong Acid + Base
High hazard corrosive reaction
Acid + Ammonia
Respiratory and corrosion hazards
Glucose Combustion
Relatively safe organic reaction
Methane Combustion
Flammable gas hazards
Limestone + Acid
Acid handling precautions
Iron Oxidation
Minimal safety concerns
๐ Safety Information Features
๐ด GHS Classifications
Standard H-codes (H314, H290, etc.) for consistent hazard identification.
โ ๏ธ Severity Levels
Color-coded warnings: ๐ด Extreme, ๐ High, ๐ก Medium, ๐ข Low hazards.
๐ก๏ธ Precautionary Statements
Specific safety recommendations for handling each chemical.
๐ Signal Words
Standard "Danger" or "Warning" classifications per GHS guidelines.
๐จ Safety Color Code
Extreme Hazard
Fatal, severe burns, extreme toxicity
High Hazard
Serious injury, corrosive, harmful
Medium Hazard
Irritant, mild toxicity, caution required
Low Hazard
Minimal risk, general precautions
๐ป Safety Information API
Integrate safety analysis into your applications:
Enhanced Chemical Equation Balancer with PubChem Validation
Enhanced Stoichiometry with PubChem Data
Compound Comparison
โน๏ธ About CREB-JS
Chemical Reaction Equation Balancer with Advanced Features
Project Overview
CREB-JS is a comprehensive chemical equation balancer and stoichiometry calculator, enhanced with real chemical data from the PubChem database. This project combines robust equation balancing algorithms with modern web technologies to provide an intuitive chemical computation toolkit.
Equation Balancing
Advanced algorithms to balance complex chemical equations automatically with detailed error handling and validation.
Stoichiometry
Calculate molar relationships, convert between units, and perform comprehensive stoichiometric analysis.
PubChem Integration
Access real chemical data including molecular weights, formulas, SMILES, and comprehensive compound information.
Compound Search
Search compounds by name, CID, SMILES, or molecular formula with intelligent matching and suggestions.
Analysis Tools
Compare compounds, analyze molecular properties, and perform enhanced stoichiometric calculations.
Modern Web Stack
Built with TypeScript, modern ES modules, comprehensive testing, and responsive design principles.
Technical Stack
Core: TypeScript, Rollup, Jest
Integration: PubChem REST API, Modern HTTP Client
Build: Multiple output formats (CJS, ESM, UMD)
Testing: Comprehensive unit and integration tests
๐ API Documentation
Complete reference for CREB-JS APIs and methods
๐งช ChemicalEquationBalancer
The core class for balancing chemical equations with advanced parsing and validation.
Description
Creates a new ChemicalEquationBalancer instance with optional configuration.
Parameters
options (optional) - Configuration object with the following properties:โข
strictMode: boolean - Enable stricter parsing (default: false)โข
maxIterations: number - Maximum balancing attempts (default: 100)โข
timeout: number - Timeout in milliseconds (default: 5000)
Example
Description
Balances a chemical equation and returns the balanced equation as a string.
Parameters
equation - The unbalanced chemical equation string
Returns
Balanced chemical equation string with coefficients
Example
Description
Calculates stoichiometric relationships for a given compound and amount.
Parameters
equation - Balanced chemical equationcompound - Target compound formulaamount - Amount in moles
Returns
Object containing molar relationships for all compounds in the equation
Example
Description
Balance chemical equations using compound names instead of formulas. Automatically resolves compound names to chemical formulas using PubChem database and provides enhanced results with compound information.
Parameters
equation - Chemical equation with compound names (e.g., "water + sodium = sodium hydroxide + hydrogen")
Returns
Promise resolving to enhanced balance result with compound data, safety information, and balance details
Example
Description
Balance chemical equations and include comprehensive safety information for all compounds. Provides GHS hazard classifications, safety warnings, and handling recommendations.
Parameters
equation - Chemical equation string with compound formulas or names
Returns
Promise resolving to result with balanced equation, compound data, and detailed safety information
Example
๐ฌ Compound (PubChem Integration)
Access PubChem database for real chemical compound data and properties.
Description
Retrieve a compound by its PubChem Compound ID (CID).
Parameters
cid - PubChem Compound ID (numeric)
Returns
Promise resolving to a single Compound instance
Example
Description
Search for compounds by common or IUPAC name. Returns array of all matching compounds.
Parameters
name - Common name, IUPAC name, or synonym of the compound
Returns
Promise resolving to array of Compound instances
Example
Description
Convenience method to get the first compound matching a name, or null if not found.
Parameters
name - Common name, IUPAC name, or synonym of the compound
Returns
Promise resolving to a single Compound instance or null
Example
Description
Search for compounds using SMILES notation. Returns array of all matching compounds.
Parameters
smiles - SMILES string representation of the molecule
Returns
Promise resolving to array of Compound instances
Example
Description
Convenience method to get the first compound matching a SMILES string.
Parameters
smiles - SMILES string representation of the molecule
Returns
Promise resolving to a single Compound instance or null
Example
Description
Search for compounds by molecular formula. Returns array of all compounds with matching formula (up to 100 results).
Parameters
formula - Molecular formula (e.g., "H2O", "C6H12O6", "C9H8O4")
Returns
Promise resolving to array of Compound instances
Example
Description
Convenience method to get the first compound matching a molecular formula.
Parameters
formula - Molecular formula (e.g., "H2O", "C6H12O6", "C9H8O4")
Returns
Promise resolving to a single Compound instance or null
Example
๐ Compound Properties
Available properties on Compound instances retrieved from PubChem:
Basic Properties
cid- PubChem Compound IDname- Primary compound namemolecularFormula- Chemical formulamolecularWeight- Molecular weight (g/mol)
Structural Data
smiles- SMILES notationinchi- InChI identifierinchiKey- InChI KeyiupacName- IUPAC systematic name
Physical Properties
meltingPoint- Melting point (ยฐC)boilingPoint- Boiling point (ยฐC)density- Density (g/cmยณ)solubility- Water solubility
Chemical Properties
charge- Formal chargecomplexity- Structural complexityheavyAtomCount- Number of heavy atomssynonyms- Array of name synonyms
โ๏ธ EnhancedStoichiometry
Advanced stoichiometric calculations with PubChem validation and enhanced features.
Description
Performs equation balancing with PubChem validation and enhanced stoichiometric analysis.
Parameters
equation - Chemical equation to balance and analyze
Returns
Promise resolving to an object containing:
balancedEquation- The balanced equationvalidation- PubChem validation resultscompounds- Array of PubChem compound datamassBalance- Mass balance verificationstoichiometry- Detailed stoichiometric relationships
Example
Description
Calculate required reagent quantities for a chemical reaction based on desired product amount. Includes molecular weight data from PubChem for accurate mass calculations.
Parameters
equation - Chemical equation stringtargetCompound - Formula of the target product compounddesiredAmount - Desired amount of target compoundunit - Unit for calculations ('moles' or 'grams', default: 'moles')
Returns
Promise resolving to detailed reagent quantity calculations with molecular data
Example
Description
Analyze reaction efficiency by comparing theoretical vs actual yields for products. Provides detailed efficiency metrics and identifies limiting reagents.
Parameters
equation - Balanced chemical equationactualYields - Object mapping compound formulas to their actual yields
Returns
Promise resolving to comprehensive efficiency analysis with yield percentages and recommendations
Example
๐ง Error Handling
CREB-JS provides comprehensive error handling for robust applications:
๐ Type Definitions
CREB-JS is fully typed with TypeScript. Key interfaces include:
๐ก Code Examples
Practical examples and real-world usage patterns
๐ค Basic Equation Balancing
Start with simple equation balancing for common chemical reactions:
๐งฎ Stoichiometric Calculations
Calculate molar relationships and quantities in chemical reactions:
๐ฌ PubChem Integration
Access real chemical data from the PubChem database:
โ๏ธ Enhanced Stoichiometry
Combine equation balancing with PubChem validation for accurate calculations:
๐ Compound Comparison
Compare multiple compounds side-by-side for research and analysis:
๐ Batch Processing
Process multiple equations or compounds efficiently:
๐ ๏ธ Error Handling & Validation
Robust error handling for production applications:
๐ Browser Integration
Using CREB-JS in web applications with modern frameworks:
โ๏ธ Compound Comparison
Compare chemical compounds side by side
Compare Compounds
๐ User Guide
Complete guide to using CREB-JS effectively
Getting Started
CREB-JS provides comprehensive chemical equation balancing and analysis. Start with basic equation balancing and progress to advanced PubChem integration.
- Install the package:
npm install creb-js - Import the balancer:
import { ChemicalEquationBalancer } from 'creb-js' - Create an instance and balance equations
Best Practices
- Use standard chemical notation (H2O, CO2, etc.)
- Include states when relevant (g), (l), (s), (aq)
- Leverage PubChem integration for accurate molecular data
- Cache compound data when performing multiple calculations