How can I install latexindent on macOS?

I found a solution. Latexindent was not present using tlmgr at first, but after updating repository and trying again, I was able to install it.

For anyone else, this is what I did (root required):

sudo tlmgr option repository ctan
sudo tlmgr update --self
sudo tlmgr install latexindent

So probably outdated or a wrong repo URL at first.

ctan is just an alias for

OK, things are a little bit different now:

brew cask install basictex
sudo tlmgr install latexindent
cpan -i Log::Log4perl Log::Dispatch::File YAML::Tiny File::HomeDir Unicode::GCString

and if you want to have the LaTeX Workshop extension on Visual Studio Code working, add the line

"latex-workshop.latexindent.path": "/Library/TeX/texbin/latexindent"

in the settings.json, you need to also install

sudo tlmgr install latexmk

tested on macOS Catalina 10.15.4.

For anyone trying to install on a clean Mojave installation (macOS 10.14.1, November 2018) so that it works with Atom and other IDEs, there are some more steps required.

First, because some of the perl helper modules require compilation, you'll need a working installation of C and perl:

  1. Make sure that you have Xcode installed and working, including command line tools.

    sudo xcode-select --switch /Library/Developer/CommandLineTools

  2. Make the header files for c etc. available; see the comment from @Maxx here (

I quote:

If we are using XCode 10, you will notice that if you navigate to /usr in the Finder, you will not see a folder called 'include' anymore which is why the terminal complains of the absence of the header files which is contained inside the 'include' folder. In this release statement,… (you navigate to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg and run that package to have the 'include' folder installed). Then you should be good to go.

  1. Install cpan through the terminal to help with perl installations:

cpan App::cpanminus

The next step is to get Latexindent working as a standalone tool:

  1. Install it using tlmgr as described elsewhere on this page
  2. Download the entire Latexindent zip from
  3. Open a terminal window
  4. In the terminal navigate to the "helper-scripts" directory
  5. Run sudo perl to get all of the other required perl modules installed.

You can now test by opening a new terminal and navigating to the directory where your .tex file is (let`s call it test.tex). Once there, you can test it without changing your file: test.tex

From this point on there are many more useful examples in the documentation on readthedocs or the CTAN Package PDF.

This means that now works with atom-beautify.