Tools

Complete Guide to LibreOffice for Word and Excel Repair

LibreOffice is rarely marketed as a repair tool, and that is a mistake. For damaged .docx, .xlsx, .doc, and .xls files, opening the file in LibreOffice and saving it back to the same format is one of the highest-success, lowest-effort repair techniques available. The reason is structural: LibreOffice’s parser is more permissive than Microsoft’s, so files with non-fatal XML errors that Word or Excel reject often open cleanly in LibreOffice, and re-saving them produces a clean output that Word and Excel will then accept.

This guide covers when LibreOffice is the right first attempt, how to install it, the GUI and command-line recipes that actually work, and the specific things LibreOffice cannot do — most importantly, the cases where macros, complex layouts, or password-protected files mean LibreOffice is the wrong tool.

When to use LibreOffice

LibreOffice is the right tool for:

Recovering Word and Excel files Microsoft Office refuses to open. The most common scenario. A .docx that Word reports as corrupt frequently opens without complaint in LibreOffice Writer. Re-saving as .docx then produces a file that Word accepts. The same pattern works for .xlsx in Calc.

Recovering older binary formats (.doc, .xls). LibreOffice maintains strong support for legacy Microsoft binary formats, including some files that modern Office versions handle poorly. For .doc files from Word 95 or older Excel formats from 5.0 onwards, LibreOffice is sometimes more reliable than Office itself.

Batch repair of many files. LibreOffice’s headless mode lets you run conversion across a directory of files without opening the GUI. For a folder of fifty damaged spreadsheets, this is hours faster than opening and re-saving each by hand.

Fixing files with the wrong extension. A file saved with .doc that is actually .docx, or vice versa. LibreOffice’s --infilter flag lets you force interpretation as a specific format, regardless of the filename.

Producing PDFs from broken Office files. When the source file is too damaged to recover fully but the visible content is intact, exporting to PDF preserves the readable output even if the original cannot be saved cleanly.

LibreOffice is not the right tool for:

Files with critical VBA macros. LibreOffice uses its own Basic interpreter, which is not bytecode-compatible with VBA. Simple macros may transfer; complex automation, ActiveX controls, and add-in dependencies will not. If macros are essential, use Microsoft’s “Open and Repair” feature first, and treat LibreOffice as a fallback for the data only.

Files with intricate layout that must round-trip perfectly. LibreOffice’s rendering of complex Word layouts — heavily styled tables, advanced numbering, equation-heavy documents — is close but not identical to Word’s. For documents where formatting fidelity is non-negotiable, recover the file with LibreOffice but reopen and verify in Word before relying on it.

Password-protected files where the password is lost. LibreOffice prompts for the password and does not bypass it. Lost-password recovery is a separate problem requiring different tools.

Severely corrupted files. LibreOffice’s tolerance has limits. If LibreOffice itself reports the file as damaged or unreadable, escalate to a dedicated repair tool — the Microsoft Open and Repair feature, Stellar Repair for Excel, or Stellar Repair for Word.

Installation

Windows

Download the installer from libreoffice.org/download. Choose the “Fresh” branch for the newest features or the “Still” branch for the more conservative release with longer testing. For repair work, either is fine; Still is slightly more stable.

Run the installer with default options. The installation includes Writer (Word equivalent), Calc (Excel equivalent), Impress, Draw, Base, and Math, plus the soffice.exe command-line entry point. The installer adds the program folder to your Start menu but does not add it to PATH. To use the command line, either invoke the full path:

"C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to docx broken.docx

…or add C:\Program Files\LibreOffice\program to your PATH environment variable so soffice works directly.

macOS

Download the .dmg from libreoffice.org/download and drag LibreOffice to your Applications folder. The command-line tool is at /Applications/LibreOffice.app/Contents/MacOS/soffice. To use it conveniently, create a symlink:

sudo ln -s /Applications/LibreOffice.app/Contents/MacOS/soffice /usr/local/bin/soffice

After this, soffice works from any terminal. Homebrew is an alternative install path:

brew install --cask libreoffice

Linux

LibreOffice is in every major distribution’s package repository:

# Debian, Ubuntu, Mint
sudo apt install libreoffice

# Fedora
sudo dnf install libreoffice

# Arch
sudo pacman -S libreoffice-fresh

The libreoffice and soffice commands are both available after installation; they are the same tool.

Verify the install with:

soffice --version

Common recipes

All examples use soffice as the command name. Substitute libreoffice or the full Windows path as needed.

Repair a damaged Word file (GUI)

  1. Open LibreOffice Writer.
  2. File → Open, select the damaged .docx or .doc file.
  3. If LibreOffice prompts about formatting issues, click through; the file usually opens.
  4. File → Save As, choose the same format (Word 2007–365 .docx or Word 97–2003 .doc), save under a new filename.
  5. Open the new file in Microsoft Word to confirm the repair.

If LibreOffice itself fails to open the file, the corruption is more severe than its parser can handle. Try a different tool.

Repair a damaged Excel file (GUI)

Same pattern, in Calc:

  1. Open LibreOffice Calc.
  2. File → Open, select the damaged .xlsx or .xls file.
  3. Save As, same format, new filename.
  4. Open in Excel to verify.

For Excel files specifically, Calc sometimes recovers data that Excel’s own “Open and Repair” misses, particularly for files where the workbook structure is intact but a single sheet’s XML is malformed.

Headless repair for a single file

Headless mode runs LibreOffice without the GUI, useful for scripts and batch operations:

soffice --headless --convert-to docx broken.docx --outdir repaired/

This reads broken.docx, parses it with LibreOffice’s Writer engine, and writes a clean broken.docx to the repaired/ directory. The conversion-back-to-the-same-format pattern is what produces the repair: LibreOffice rebuilds the OOXML structure from its in-memory representation.

For Excel:

soffice --headless --convert-to xlsx broken.xlsx --outdir repaired/

A running LibreOffice GUI instance will block headless invocations. Close all open LibreOffice windows before running, or use --nolockcheck to bypass the check (with the caveat that simultaneous file access may produce inconsistent results).

Batch repair across a directory

Headless mode does not natively accept wildcards; use a shell loop:

Bash (macOS, Linux):

for f in damaged_files/*.docx; do
  soffice --headless --convert-to docx "$f" --outdir repaired/
done

PowerShell (Windows):

Get-ChildItem damaged_files\*.docx | ForEach-Object {
  & "C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to docx $_.FullName --outdir repaired
}

Process files one at a time. LibreOffice headless is not safe to run multiple instances against the same user profile simultaneously.

Force format detection on misnamed files

If a file has the wrong extension — for example, a .docx saved as .txt by an email client — --infilter forces the parser:

soffice --headless --infilter="MS Word 2007 XML" --convert-to docx wrongly_named.txt --outdir repaired/

Common filter names:

  • "MS Word 2007 XML" for .docx
  • "MS Excel 2007 XML" for .xlsx
  • "MS Word 97" for legacy .doc
  • "MS Excel 97" for legacy .xls
  • "writer8" for .odt
  • "calc8" for .ods

The full filter list is in LibreOffice’s source under filter/source/config/fragments/filters/.

Export a damaged file to PDF as last resort

When the file opens but cannot be saved cleanly back to its original format:

soffice --headless --convert-to pdf broken.docx --outdir repaired/

This produces a PDF capturing the visible content, even if the underlying structure is too damaged to round-trip as .docx. You lose editability but preserve the document.

Convert between formats

Headless conversion handles format translation as well as repair:

# .doc to .docx
soffice --headless --convert-to docx old.doc --outdir converted/

# .xlsx to .csv
soffice --headless --convert-to csv data.xlsx --outdir converted/

# .docx to plain text
soffice --headless --convert-to txt document.docx --outdir converted/

For CSV output, the default uses commas; specify field separator and encoding via the filter syntax:

soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":"44,34,76,1,,0" data.xlsx --outdir converted/

The numeric parameters control field separator (44 = comma), text delimiter (34 = double quote), encoding (76 = UTF-8), and other options. The full reference is in the LibreOffice Help under “Filter Options for Lotus, dBase and DIF Files.”

Limitations and known issues

VBA macros do not transfer cleanly. LibreOffice’s Basic interpreter shares some syntax with VBA but is not compatible at the API level. Macros that use the Word or Excel object models, ActiveX controls, or external COM references will fail or behave incorrectly. If a Word or Excel file’s value is in its macros, recovering with LibreOffice means accepting the loss of those macros.

Layout fidelity is close but not identical. LibreOffice’s rendering of complex Word and Excel files is excellent for plain content and good for moderately styled documents. For heavily styled documents — corporate templates with custom fonts, complex table designs, advanced numbering, equation-heavy academic papers — the round-trip may shift layout slightly. Always reopen the recovered file in the original application and inspect before relying on it.

No password cracking. LibreOffice prompts for passwords on protected files and does not bypass them. Lost-password recovery requires different tools and, for modern AES-encrypted Office files, is generally not feasible.

A running GUI instance blocks headless mode. This is the single most common cause of “headless conversion does nothing” reports. Close all LibreOffice windows before running a headless command, or accept the risk of --nolockcheck.

Large files consume substantial memory. LibreOffice loads the entire document into memory. For .xlsx files over a few hundred megabytes or .docx files with very large embedded media, allow extra RAM headroom or process on a more capable machine.

The first headless run after install is slow. LibreOffice initializes a user profile on first invocation. Scripts that run a single conversion will appear to hang for ten to thirty seconds the first time. Subsequent runs are fast.

Encrypted .docx and .xlsx files require the password upfront. Headless mode cannot prompt for a password. If the file is password-protected, the headless command will fail silently. Open in the GUI first, supply the password, save an unencrypted copy, then run headless conversions on the unencrypted file.

Alternatives

Microsoft’s “Open and Repair” feature is built into Word and Excel and should be tried first if you have Office installed. It is faster and integrates with the file’s original application. LibreOffice is the better fallback when “Open and Repair” fails. See the complete guide to Microsoft’s Open and Repair feature.

Stellar Repair for Excel and Stellar Repair for Word are commercial GUI tools aimed at users who need repair without command-line interaction and are willing to pay for it. They handle some severely damaged files that LibreOffice cannot, at the cost of a license fee. See the complete guide to Stellar Repair for Excel and the complete guide to Stellar Repair for Word.

DataNumen Excel Repair is a longer-established commercial tool with strong specific support for legacy .xls recovery. For binary-format Excel files where LibreOffice falls short, it is worth considering. See the complete guide to DataNumen Excel Repair.

Direct ZIP inspection is an option for technically-inclined users. Modern .docx, .xlsx, and .pptx files are ZIP containers; opening one with a ZIP tool reveals the underlying XML, which can sometimes be edited by hand to fix specific structural problems. This is a last-resort technique and requires understanding the OOXML schema.

Last verified: April 2026