npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

latex-content-renderer

v1.1.3

Published

LaTeX math equation renderer for React, React Native, Expo, Flutter, Android & iOS WebView. Render LaTeX, MathJax, KaTeX-style math, chemistry SMILES molecular structures, mhchem chemical formulas, tables, and scientific content. Universal cross-platform

Maintainers

dev_sandipandev_sandipan

Keywords

latexLaTeXtexmathjaxmathjax3mathjax-reactkatexmathmathsmathematicsmath-renderermath-renderingmath-typesettingmath-displaymath-componentmath-equationmath-formulaequationequationsformulaformulasrendererrenderrenderingtypesettingtypesetscientificsciencescientific-notationreactreact-componentreact-latexreact-mathreact-mathjaxreact-katexreact-equationreact-nativereact-native-latexreact-native-mathreact-native-mathjaxreact-native-equationexpoexpo-latexexpo-mathflutterflutter-latexflutter-mathwebviewweb-viewandroidioscross-platformuniversalchemistrychemicalchemical-formulachemical-structurechemical-equationmoleculemolecularmolecular-structuresmilessmiles-drawersmiles-renderermhchemchemfiglewis-structureorganic-chemistrylatex-to-htmllatex-parserlatex-renderlatex-rendererlatex-componentlatex-reactmath-to-htmlhtml-mathinline-mathdisplay-mathblock-mathtex-mathtex-renderercontent-renderermarkdown-mathintegralcalculusalgebranotationsuperscriptsubscriptfractionmatrixtabletabularenumerateitemizenextjsnext-jsvitecracreate-react-appeducatione-learningstemacademictextbookhomeworkquizexamlmslearning-managementdark-modethemeself-containedofflinecdnmathjax-cdnlightweighteasysimplereact-sciencescience-rendererwkwebviewandroid-webviewchemistry-rendererchemistry-equationchemistry-reactchem-equationchem-rendererchem-formulachemreactionchemical-reactionreaction-equationstructural-formulamolecular-formulaperiodic-tablebondcovalent-bondionic-bondelectron-dotlewis-dotstoichiometrybalancing-equationsinorganic-chemistrybiochemistrypharmacologydrug-structurelatex-equationlatex-mathlatex-formulalatex-displaylatex-inlinelatex-weblatex-webviewlatex-viewerlatex-converterlatex-htmllatex-stringtex-to-htmltex-rendertex-equationtex-componenttex-reacttex-displaytex-inlinetex-latexkatex-reactkatex-rendererkatex-componentkatex-mathkatex-equationkatex-alternativekatex-replacementkatex-displaykatex-renderkatex-to-htmlkatex-nativemathjax-componentmathjax-renderermathjax-equationmathjax-displaymathjax-rendermathjax-nativemathjax-webviewmathjax-htmlmathjax-nodemathjax-v3math-reactmath-react-nativemath-expomath-fluttermath-webviewmath-webmath-viewermath-editormath-convertermath-parsermath-notationmath-symbolsmath-expressionmath-markupequation-rendererequation-renderequation-componentequation-displayequation-editorequation-viewerequation-reactequation-to-htmlformula-rendererformula-renderformula-displayformula-reactformula-componentreact-formulareact-texreact-render-latexreact-render-mathreact-math-rendererreact-latex-rendererreact-chemistryreact-scientificreact-smilesreact-moleculereact-native-chemistryreact-native-formulareact-native-webview-mathreact-native-webview-latexreact-native-sciencereact-native-katexreact-native-rendererexpo-mathjaxexpo-katexexpo-equationexpo-chemistryexpo-webviewexpo-scienceexpo-rendererexpo-react-native-mathflutter-mathjaxflutter-katexflutter-equationflutter-chemistryflutter-webviewflutter-scienceflutter-rendererweb-mathweb-latexweb-equationweb-rendererweb-chemistrywebview-mathwebview-latexwebview-equationwebview-rendererwebview-htmlsmiles-reactsmiles-chemistrysmiles-moleculesmiles-notationsmiles-structuresmiles-to-imagesmiles-to-svgsmiles-parsermhchem-reactmhchem-renderermhchem-latexmhchem-formulascientific-calculatorscientific-contentscientific-rendererscientific-formulascientific-writingscientific-documentscientific-publishingphysicsphysics-equationphysics-formulatrigonometrygeometrystatisticsprobabilitylinear-algebradifferential-equationsummationsigmapithetainfinitylimitderivativegradientvectortensorpolynomiallogarithmexponentsquare-rootsqrtbinomialpermutationcombinationset-theorynumber-theorygraph-theorydiscrete-mathtypescriptjavascriptjstsnpmnpm-packagecomponentui-componentwidgetpluginlibrarymodulesdktoolkitframeworknextnextjs-latexnextjs-mathnextjs-mathjaxnextjs-katexgatsbygatsby-latexremixremix-latexvite-latexvite-mathwebpackrollupesbuildssrserver-side-renderingclient-sidehybridisomorphicmobilemobile-mathmobile-latextabletdesktopresponsiveaccessiblea11yariascreen-readersvg-mathcanvas-mathhtml-equationhtml-formulahtml-latexhtml-rendererdomvirtual-domdangerouslysetinnerhtmlinnerHTMLrichtextrich-textrich-contentcontent-displaycontent-viewerdocument-renderertextbook-rendererhomework-helperquiz-rendererexam-renderertest-rendererassessmenttutortutoringonline-educationdistance-learningmooccoursewarecurriculumclassroomstudentteacherprofessoruniversityschoolcollegeresearchpaperjournalpublicationthesisdissertationconferencepresentationslidewhiteboardnotebooknotesflashcardstudyreviewpracticeexerciseproblem-setworksheetsolutionanswerstep-by-stepworked-exampleauto-heightauto-resizeresponsive-webviewinject-htmlhtml-stringself-sizinglight-modedark-themelight-themethemingcustomizableconfigurablezero-configplug-and-playdrop-inone-linerno-configbatteries-includedall-in-onemulti-platformmultiplatformhybrid-apppwaprogressive-web-appelectrontauricapacitorioniccordovanativescriptstreamingstreaming-mathstreaming-latexllmllm-mathllm-renderingaiai-mathai-renderingchatgptchatgpt-mathchatgpt-latexclaudegeminiopenaigptgpt-mathgpt-latexai-responseai-chatchat-mathchat-latexrealtimerealtime-mathincrementalincremental-renderinglive-previewtypewriterariaaria-matharia-labelscreen-reader-mathwcagaccessibility-matha11y-mathlatex-to-svglatex-to-imagelatex-to-pnglatex-exportmath-to-svgmath-to-imagemath-to-pngequation-to-svgequation-to-imagesvg-exportdata-urltex-to-svgmathjax-svgcopilotanthropicdeepseekmistralllamahuggingface

Readme

latex-content-renderer

One package to render LaTeX math, chemistry (SMILES / mhchem), tables, figures, and formatted text — on every platform.

Works with React, React Native (Expo), Flutter, Android WebView, iOS WKWebView, and anything that can render HTML.

Powered by MathJax 3 + SmilesDrawer.


What does this package do?

You give it a string containing LaTeX, math, chemistry, or formatted text — it converts it to beautiful rendered HTML.

Input:  "The quadratic formula: $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$"
Output: Beautiful rendered math equation in the browser

No setup hassle. No MathJax configuration. No boilerplate. Just import and use.


Install

npm install latex-content-renderer

Quick Start (React)

Step 1: Add MathJax CDN to your HTML <head>:

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" async></script>

Step 2: Use the component:

import { SciContent } from 'latex-content-renderer';

function App() {
  return (
    <SciContent content="The quadratic formula: $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$" />
  );
}

That's it. The math renders beautifully.


What can it render?

| Feature | Input example | What it does | |---------|---------------|-------------| | Inline math | $E = mc^2$ | Renders math inline with text | | Display math | $$\int_0^\infty e^{-x^2} dx$$ | Renders math as a centered block | | Chemistry formulas | $\ce{H2O}$, $\ce{2H2 + O2 -> 2H2O}$ | Chemical equations via mhchem | | SMILES structures | <smiles>CCO</smiles> | 2D molecular structure diagrams | | Tables | \begin{tabular}{\|c\|c\|}...\end{tabular} | HTML tables with borders | | Images | \includegraphics{url} or ![alt](url) | Embedded images | | Figures | \begin{figure}...\caption{...}\end{figure} | Figures with captions | | Lists | \begin{enumerate}\item ...\end{enumerate} | Numbered & bullet lists | | Bold/Italic | \textbf{bold}, \textit{italic} | Text formatting | | Colors | \textcolor{red}{text}, \colorbox{yellow}{text} | Colored text & highlights | | Monospace | \texttt{code} | Monospaced text |


Usage by Platform

React (Next.js / Vite / CRA)

import { SciContent } from 'latex-content-renderer';

function MathPage() {
  return (
    <div>
      <SciContent content="Solve: $x^2 - 5x + 6 = 0$" />
      <SciContent content="Water: $\ce{H2O}$" />
    </div>
  );
}

React Native / Expo

npm install react-native-webview  # peer dependency
import { SciContentNative } from 'latex-content-renderer/native';

function MathScreen() {
  return (
    <SciContentNative
      content="Ethanol structure: <smiles>CCO</smiles>"
      theme="dark"
      fontSize={16}
    />
  );
}

Flutter / Android / iOS (any WebView)

Use getHtml() to get a self-contained HTML string you can load in any WebView:

import { getHtml } from 'latex-content-renderer';

const html = getHtml('Evaluate: $$\\int_0^1 x^2 \\, dx$$', {
  theme: 'light',
  fontSize: 18,
});

// Flutter:  WebView(html: html)
// Android:  webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null)
// iOS:      webView.loadHTMLString(html, baseURL: nil)

Core function only (no React)

import { processContent } from 'latex-content-renderer';

const html = processContent('Derivative: $\\frac{d}{dx} x^n = nx^{n-1}$');
// Returns HTML string — still needs MathJax loaded in the browser to render math

Plain HTML (CDN — no npm, no build tools)

If you're NOT using React/npm/build tools and just have a plain HTML file, add one script tag and it works. MathJax and SmilesDrawer are auto-loaded for you:

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/latex-content-renderer/dist/latex-content-renderer.min.global.js"></script>
</head>
<body>
  <div id="output"></div>

  <script>
    // One line — renders math, chemistry, tables, everything
    LatexRenderer.render('#output', 'The quadratic formula: $x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$');
  </script>
</body>
</html>

That's it. One script tag. MathJax is auto-injected. No configuration needed.

You can also use the lower-level API if you want more control:

<script>
  // Just get the HTML (you handle MathJax yourself)
  var html = LatexRenderer.processContent('$E = mc^2$');
  document.getElementById('output').innerHTML = html;
</script>

What's available via CDN (LatexRenderer.*):

| Function | What it does | |----------|-------------| | LatexRenderer.render(selector, text) | Easiest — process + render + typeset in one call | | LatexRenderer.processContent(text) | Convert LaTeX string → HTML | | LatexRenderer.getHtml(text, opts) | Get complete HTML page for WebViews | | LatexRenderer.addAccessibility(html) | Add ARIA labels for screen readers | | LatexRenderer.createStreamingState() | Create buffer for AI streaming | | LatexRenderer.feedChunk(state, chunk) | Feed a chunk from AI stream | | LatexRenderer.flushStream(state) | Flush remaining buffered text | | LatexRenderer.latexToSvg(tex) | LaTeX → SVG (needs tex-svg.js) | | LatexRenderer.latexToDataUrl(tex) | LaTeX → base64 data URL |

Note: The CDN build does NOT include the React components (SciContent, SciContentStreaming). Those require npm install and a bundler. The CDN gives you all the core functions.


AI/LLM Streaming Support

What is this and why do you need it?

Important: This package does NOT include any AI or LLM. It does NOT call ChatGPT or any API.

This feature is for developers who are already building apps that call AI APIs (ChatGPT, Claude, Gemini, DeepSeek, etc.).

The problem it solves:

When your AI API sends back a response with math, it arrives character by character (streaming). For example, the AI might be trying to send $$x = \frac{1}{2}$$, but you receive it in chunks:

Chunk 1: "The answer is $$x = \frac{"    ← incomplete math!
Chunk 2: "1}{2}"                          ← still incomplete!
Chunk 3: "$$"                             ← now it's complete

If you try to render chunk 1 right away, $$x = \frac{ is broken LaTeX — it shows as ugly text or throws errors.

What this feature does: It buffers incomplete math and only renders complete equations. Your users see clean text while math is being typed, then the full beautiful equation appears once it's complete.

React component (easiest way)

import { SciContentStreaming } from 'latex-content-renderer';

// In your AI chat app:
function AIChatBubble({ text, isStreaming }) {
  return (
    <SciContentStreaming
      content={text}           // The text received so far from the AI
      isStreaming={isStreaming} // true while AI is still sending
      showCursor={true}        // Show blinking cursor while streaming
      debounceMs={100}         // Re-render at most every 100ms
    />
  );
}

Lower-level API (for custom setups)

import { createStreamingState, feedChunk, flushStream, processContent } from 'latex-content-renderer';

const state = createStreamingState();

// As each chunk arrives from your AI API:
for await (const chunk of myAiStream) {
  const safeText = feedChunk(state, chunk);  // Buffers incomplete math
  const html = processContent(safeText);     // Only complete math is rendered
  myElement.innerHTML = html;
}

// When the AI finishes sending:
const finalText = flushStream(state);        // Release any remaining buffered text
const html = processContent(finalText);
myElement.innerHTML = html;

What gets buffered?

| Delimiter | Waits until it sees | |-----------|-------------------| | $...$ | Closing $ | | $$...$$ | Closing $$ | | \(...\) | Closing \) | | \[...\] | Closing \] | | \begin{equation} | Matching \end{equation} |

Everything else (plain text, HTML) passes through immediately.


LaTeX to SVG Export

Convert any LaTeX equation to an SVG image you can save, share, or embed.

Use cases:

  • Save equations as SVG files for presentations or PDFs
  • Embed math in emails or static HTML pages (as <img> tags)
  • Generate shareable math images

Setup

This feature requires MathJax SVG output. Use tex-svg.js instead of tex-mml-chtml.js:

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" async></script>

If you don't need SVG export and only need rendering, tex-mml-chtml.js is fine.

Usage

import { latexToSvg, latexToDataUrl, latexToHtmlString } from 'latex-content-renderer';

// Get raw SVG string
const svg = await latexToSvg('E = mc^2');
document.getElementById('output').innerHTML = svg;

// Get data URL for <img> tags
const dataUrl = await latexToDataUrl('\\frac{a}{b}');
const img = document.createElement('img');
img.src = dataUrl;  // "data:image/svg+xml;base64,..."

// Get rendered HTML string (needs tex-mml-chtml.js instead)
const html = await latexToHtmlString('x^2 + y^2 = r^2');

Accessibility (Screen Reader Support)

Add ARIA labels to rendered math so screen readers can read equations aloud.

Use cases:

  • Make your education app WCAG compliant
  • Help visually impaired students understand math
  • Required for government and accessibility-audited projects

Usage

import { processContent, addAccessibility } from 'latex-content-renderer';

// Step 1: Process the content normally
const html = processContent('The circle equation: $x^2 + y^2 = r^2$');

// Step 2: Add accessibility attributes
const accessibleHtml = addAccessibility(html);

What it does:

  • Wraps math in <span role="math" aria-label="x squared plus y squared equals r squared">
  • Converts Greek letters: $\alpha$ → label says "alpha"
  • Converts fractions: $\frac{a}{b}$ → label says "a over b"
  • Adds role="table" and aria-label to tables
  • Adds role="img" to chemistry structure diagrams
  • Adds alt text to images that don't have one

SMILES Chemistry Formats

7 ways to input chemical structures — all render as 2D molecular diagrams:

| Format | Example | |--------|---------| | <smiles>CCO</smiles> | XML-style tag | | [smiles]CCO[/smiles] | BBCode-style tag | | <mol>CCO</mol> | Molecule tag | | <molecule>CCO</molecule> | Full molecule tag | | <chem>CCO</chem> | Chemistry tag | | \smiles{CCO} | LaTeX command | | SMILES: CCO | Labeled (on its own line) |

To enable SMILES rendering, add SmilesDrawer to your HTML:

<script src="https://unpkg.com/[email protected]/dist/smiles-drawer.min.js"></script>

Full API Reference

Components

| Component | Platform | Import | |-----------|----------|--------| | SciContent | React web | import { SciContent } from 'latex-content-renderer' | | SciContentNative | React Native | import { SciContentNative } from 'latex-content-renderer/native' | | SciContentStreaming | React web (AI) | import { SciContentStreaming } from 'latex-content-renderer' |

Functions

| Function | What it does | |----------|-------------| | processContent(text, opts?) | Convert LaTeX string → HTML string | | getHtml(text, opts?) | Get complete HTML page for WebViews | | addAccessibility(html, opts?) | Add ARIA labels to processed HTML | | createStreamingState() | Create streaming buffer for AI responses | | feedChunk(state, chunk) | Feed a chunk, get safe-to-render text back | | flushStream(state) | Get all remaining buffered text | | latexToSvg(tex, opts?) | LaTeX → SVG string (needs tex-svg.js) | | latexToHtmlString(tex, opts?) | LaTeX → rendered HTML string | | latexToDataUrl(tex, opts?) | LaTeX → base64 data URL |


Changelog

v1.1.0

  • AI Streaming support — Buffer incomplete math during LLM streaming. New SciContentStreaming component + createStreamingState/feedChunk/flushStream API
  • SVG exportlatexToSvg(), latexToHtmlString(), latexToDataUrl() to convert equations to images
  • AccessibilityaddAccessibility() adds ARIA labels and screen-reader descriptions

v1.0.1

  • Fixed MathJax equations inheriting wrong color
  • Improved SMILES rendering reliability
  • Added skipProcessing option

v1.0.0

  • Initial release: LaTeX math, chemistry (SMILES + mhchem), tables, figures, lists, text formatting
  • React web + React Native + universal getHtml()

Contributing

  1. Fork: github.com/sandipan-das-sd/scirender
  2. Branch: git checkout -b feature/my-feature
  3. Commit and open a Pull Request

Questions? Email: [email protected]


Support the Project

| Method | Details | |--------|---------| | UPI (India) | [email protected] via GPay / PhonePe / Paytm | | PayPal | paypal.me/sandipandas3002 | | GitHub | Star the repo ⭐ |


Author

Sandipan Das@sandipan-das-sd · [email protected]

License

MIT — free for personal and commercial use.