loglux2k downloadsConvert LaTeX equations from ChatGPT and AI assistants to the correct Markdown format: block equations to display math, inline to inline math.
A simple Obsidian plugin with a button and command to fix LaTeX math delimiters in your notes. It converts \[…\] → $$…$$ and \(…\) → $…$, while intelligently detecting and converting plain parentheses and brackets that contain mathematical expressions. Code blocks are always preserved.
When you copy content with mathematical formulas from ChatGPT, OpenWebUI, or other AI assistants into Obsidian, the math often comes in LaTeX format using \(…\) for inline math and \[…\] for display math. However, Obsidian uses $…$ and $$…$$ delimiters.
Instead of manually finding and replacing each formula, just click one button and all math delimiters in your note will be fixed automatically! 🪄
While there are other plugins for converting LaTeX delimiters, this one focuses on:
(x=y) and (0/0).$…$ and non-math text alone.$…$ and $$…$$ delimiters.```…``` and ~~~…~~~).(x=y) – simple variable equations(x\to 1) – LaTeX expressions(0/0) – fractions(3x^{2} - 3 = 0) – polynomials(3x^{2} - 3)' – derivatives with trailing primes(p) – single-letter variables(345{,}678{,}123) – LaTeX formatted large numbers[ \frac{a}{b}(c + d) = \frac{ac}{b} + \frac{ad}{b} ] → converts to display math> \[...\] (quoted backslash blocks)> [...] (quoted bracket blocks) – handles multi-line quoted brackets from AI assistants| Input format | Detected as | Output format |
|---|---|---|
\(...\) |
inline | $...$ |
\[...\] |
block | $$...$$ |
> \[...\] (quoted backslash block) |
block | > $$...$$ |
> [...] (quoted bracket block, multi-line) |
block | > $$...$$ |
[ ... ] (if on separate lines and contains math) |
block | $$...$$ |
[ ... ] (single line with LaTeX, e.g. from AI) |
block | $$...$$ |
( ... ) (if contains math) |
inline | $...$ |
```...``` or ~~~...~~~ |
code block | unchanged |
manifest.jsonmain.js.obsidian/plugins/fix-math/npm install
npm run build
main.js next to main.ts.manifest.json and the built main.js into your vault's plugin folder:.obsidian/plugins/fix-math/.Ctrl/Cmd+P) and run "Fix math (current file)"If you select some text before running the command, only the selected text will be converted — the rest of the file is left untouched. This is useful when you want to convert a single paragraph or a freshly pasted block without affecting already-processed content.
The plugin does not set a default hotkey, but you can add one yourself:
This makes it very convenient to fix maths in the current note with a single key press.
For best results with AI-generated math content, go to Settings → Editor and disable the option "Convert HTML content to Markdown on paste".
With this setting off, pasted content keeps its original structure — bracket math blocks [...], matrix row separators \\, and equation signs = are all preserved as exported. The plugin then handles all known ChatGPT export artefacts automatically.
If you prefer to keep the setting enabled, the plugin also handles the different artefacts produced by that mode.
When copying content from ChatGPT, Claude, OpenWebUI, or similar AI assistants:
\( ... \) and \[ ... \]$ ... $ and $$ ... $$If you've already pasted text and the math expressions don't have any delimiters (just plain LaTeX commands like \frac{a}{b} or \sum_{i=1}^n):
$$ ... $$)$ ... $)This is Obsidian's built-in feature for wrapping selected text in math delimiters.
Example:
\frac{a}{b} = \frac{c}{d}$$\frac{a}{b} = \frac{c}{d}$$Before:
This is inline math \(x^2 + y^2 = z^2\) in text.
Display math:
\[
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\]
After:
This is inline math $x^2 + y^2 = z^2$ in text.
Display math:
$$
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$
Before:
And a mixed example:
(0/0) is an indeterminate form, and (3x^{2}-3)' = 6x.
Simple equations like (x=y) are also converted.
After:
And a mixed example:
$0/0$ is an indeterminate form, and $(3x^{2}-3)' = 6x$.
Simple equations like $x=y$ are also converted.
Before:
> Here's an important formula:
> \[
> E = mc^2
> \]
After:
> Here's an important formula:
> $$ E = mc^2 $$
Before:
> You can use the expression
> [
> \cos(\angle DEF) = \frac{-92.99}{163.48}
> ]
> to find the angle.
After:
> You can use the expression
> $$
\cos(\angle DEF) = \frac{-92.99}{163.48}
$$
> to find the angle.
Before:
The student correctly applied the distributive property:
[ \frac{a}{b}(c + d) = \frac{a(c + d)}{b} = \frac{ac + ad}{b} = \frac{ac}{b} + \frac{ad}{b} ]
This shows understanding of algebraic fractions.
After:
The student correctly applied the distributive property:
$$
\frac{a}{b}(c + d) = \frac{a(c + d)}{b} = \frac{ac + ad}{b} = \frac{ac}{b} + \frac{ad}{b}
$$
This shows understanding of algebraic fractions.
Before:
The population is approximately (7{,}900{,}000{,}000) people.
Scientific notation uses (6{.}022 \times 10^{23}) for Avogadro's number.
After:
The population is approximately $7{,}900{,}000{,}000$ people.
Scientific notation uses $6{.}022 \times 10^{23}$ for Avogadro's number.
The plugin intelligently detects mathematical expressions based on:
\to, \sin, \cos, \text{...}, etc.123{,}456 (thousands), 1{.}234 (decimals)+, -, *, /, =, <, >_, ^ (subscript/superscript), →, ∞, ±, ≥, ≤3 + 5, x^20, -1, 3.14p, v, x'x=y, a<b, f>g(about this topic) – contains full words```math content``` – never touched$formula$ and $$formula$$ – already correct(hello world) – no mathematical indicators[text](url) and [text]: url – recognised as links, not math[[page name]] – Obsidian internal links[^ref] – footnote referencesBy default, block maths is wrapped as:
$$
...
$$
If you prefer display formulae without extra blank lines around $$, you can tweak the convertMath() implementation in main.ts (or the compiled main.js) to change how block maths is wrapped.
``` or ~~~ fences\[...\] and \(...\) delimiters$...$ delimiters are never modifiedMIT