HTML to LaTeX
Paste HTML, or copy part of a web page and paste it here, and this HTML to LaTeX converter writes LaTeX as you go. Headings, lists, tables, links and code carry over, and equations rendered by KaTeX, MathJax or Wikipedia come back as real LaTeX math.
LaTeX
\subsection{Gaussian integral}
The \textbf{Gaussian integral} of $e^{-x^2}$ over the real line equals $\sqrt{\pi}$, about 1.77 — 100\% of the normal density.
\[
\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}
\]
\begin{itemize}
\item Square it and use \emph{polar coordinates}.
\item See \href{https://en.wikipedia.org/wiki/Gaussian_integral}{Wikipedia}.
\end{itemize}
\begin{table}[htbp]
\centering
\begin{tabular}{lr}
\toprule
\textbf{Method} & \textbf{Steps} \\
\midrule
Polar & 3 \\
Series & 5 \\
\bottomrule
\end{tabular}
\end{table}Add to your preamble: \usepackage{amsmath} \usepackage{booktabs} \usepackage{hyperref}
Have a scan, a photo or a PDF instead of a web page? Convert it to LaTeX.
Convert a fileHow to convert HTML to LaTeX
Paste HTML or copy from a page
Select part of a web page, copy it, and paste it into the box: the HTML to LaTeX converter reads the HTML on the clipboard, not just the plain text. You can also paste source code or upload a saved .html file. Everything runs in your browser.
Choose the output
Body only gives content for an existing document; Complete document adds the class, packages and \begin{document}. Map <h1> to \section, to \chapter, or use the first one as the title, and pick verbatim or listings for code and tabular or longtable for tables.
Copy the LaTeX
Copy or download the .tex and add the listed \usepackage lines, such as hyperref for links. If any equation was shown on the page without its source, a note under the output says how many, so you can retype just those. Then paste the result into Overleaf or your template and compile; most pages need no further edits.
What converts, and how
Text, lists and links
Headings become sections, <b> and <strong> become \textbf, <i> and <em> become \emph, <del> becomes \sout, and sub and superscripts become math subscripts and superscripts. Lists keep nesting and start numbers, links become \href, and characters such as %, &, _, < and $ are escaped.
Equations come back as LaTeX
Rendered equations usually keep their source. KaTeX and MathJax add it to their MathML, Wikipedia stores it in an alttext attribute, and MathJax 2 keeps it in a script tag. This HTML to LaTeX converter reads all of these, plus \(…\), \[…\] and $…$ typed as text.
Tables, figures and code
Tables become booktabs tables with each column's alignment from align or text-align, and colspan cells keep their text. A figure with a figcaption becomes a figure with \caption. pre and code blocks become verbatim or lstlisting, with the language taken from the language- class.
Tips for clean results
Copy just the content
Select the article text rather than the whole page. Navigation, forms, scripts, styles, videos and inline SVG are dropped anyway, but menus written as plain lists or headings would otherwise come along. The browser's reader mode, which strips sidebars and adverts, makes a clean selection easy.
Pages that hide their math
Some sites draw equations as images or as MathJax 3 output without the source. The HTML to LaTeX converter counts these and keeps their visible text, and you can write the formula again in the equation editor.
LaTeX equation editorImages and styling
Images keep their src as the \includegraphics path, so download them next to the .tex file. Colours, fonts and CSS layout are not copied; LaTeX handles the typography from the document class.
Official references: HTML Living Standard · Pandoc manual

HTML and LaTeX questions
- How to convert HTML to LaTeX in Python?
- Call Pandoc through pypandoc: pypandoc.convert_text(html, 'latex', format='html'). For a page or two, pasting into this HTML to LaTeX converter is quicker and also recovers KaTeX and Wikipedia math.
- How to include HTML code in LaTeX?
- To show HTML source in a document, put it in a verbatim environment or use listings with language=HTML. To include what the HTML says, run it through the HTML to LaTeX converter first.
- Is there a free HTML to LaTeX converter online?
- Yes, this one. It is free, needs no sign-up and converts in your browser as you paste.
- How do I convert an HTML table to LaTeX?
- Copy the table from the page and paste it into the HTML to LaTeX converter. You get a booktabs table with bold headers and each column's alignment, ready to fine-tune in the table generator.
- How do I convert HTML to LaTeX with Pandoc?
- Run pandoc page.html -t latex -o page.tex, adding -s for a complete document. Pandoc does not read math from KaTeX or Wikipedia markup, which this page does.
- Can I turn a web page into a PDF through LaTeX?
- Yes. Convert with Complete document, compile the .tex in Overleaf or with pdfLaTeX, and you get the article typeset by LaTeX, with proper equations and hyphenation. An HTML to LaTeX pass also replaces the page's mixed fonts and spacing with consistent typography.
- How do I copy equations from a MathJax or KaTeX page as LaTeX?
- Copy the passage and paste it here; the LaTeX source stored with each formula is recovered. For one formula, right-clicking a MathJax equation also offers Show Math As TeX.
- How do I use an HTML color code in LaTeX?
- Load xcolor and define it with \definecolor{brand}{HTML}{1A73E8}, then use \textcolor{brand}{text}. The converter does not copy page colours on its own.
- How are HTML links converted to LaTeX?
- Each link becomes \href{url}{text}, and a bare address becomes \url. Both need the hyperref package, which is listed under the output.
- Can I paste straight from a web page?
- Yes. When you paste content copied from a page, the HTML on the clipboard is used, so headings, lists and math survive instead of being flattened to plain text. If you only want the words, paste with Ctrl+Shift+V instead.
- What happens to images, scripts and styling?
- Images become \includegraphics with the same path, inside a figure when they have a caption. Scripts, styles, forms, navigation and media are removed. Embedded videos and posts leave nothing behind, so add a link by hand where one matters.
- Which kinds of math does the converter recover?
- MathML with a TeX annotation from KaTeX and MathJax, Wikipedia's alttext, MathJax 2 script tags, and \(…\), \[…\], $$…$$ and $…$ written in the text.
- Can I convert a Wikipedia article to LaTeX?
- Yes. Copy the article text and paste it here. Wikipedia keeps the LaTeX of every formula, so the HTML to LaTeX output has real equations rather than images.
Have a whole page of notes, a scan or a PDF? Convert it to LaTeX that compiles.
Convert a file