pdf2svg

pdf2svg is a command-line tool for converting vector-based PDFs (like those from LaTeX) into scalable, web-ready SVGs.

use this because it is one of the best tools

install with homebrew

pdf to svg

  1. Create PDF (example for LaTeX) pdflatex mydiagram.tex

  2. Convert PDF to SVG pdf2svg mydiagram.pdf mydiagram.svg

  3. (Optional) Optimize SVG svgo mydiagram.svg

Use standalone package to created a cropped :

\documentclass{standalone}
\usepackage{tikz}  % Or any other package you're using

\begin{document}

\begin{tikzpicture}
  \draw (0,0) rectangle (3,2);
  \node at (1.5,1) {My Diagram};
\end{tikzpicture}

\end{document}