Class MarkItDown
java.lang.Object
io.github.cyber655.markitdown.MarkItDown
A Java API for Microsoft MarkItDown.
This is a thin, dependency-free wrapper that invokes the markitdown command-line tool
as a subprocess. The MarkItDown CLI (a Python package) must be installed and reachable, either on
the PATH or via an explicit path supplied to MarkItDown.Builder.executable(String).
MarkItDown md = MarkItDown.create();
String markdown = md.convert(Path.of("report.pdf"));
Instances are immutable and safe to share between threads. Each conversion spawns its own subprocess.
Security: MarkItDown performs I/O with the privileges of the current process. Sanitize inputs in untrusted environments and prefer the narrowest conversion entry point for your use case.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic MarkItDown.Builderbuilder()Creates a new client builder.convert(byte[] data, ConversionOptions options) Converts in-memory bytes to Markdown by piping them to the tool's standard input.convert(InputStream input, ConversionOptions options) Converts the contents of a stream to Markdown by piping them to standard input.Converts a file to Markdown using default options.convert(Path file, ConversionOptions options) Converts a file to Markdown.voidconvertToFile(Path input, Path output, ConversionOptions options) Converts a file and writes the Markdown directly tooutput(maps to the CLI-oflag).static MarkItDowncreate()Creates a client with default settings (markitdownon thePATH).booleanReturnstrueif themarkitdownexecutable can be located and run, i.e.Returns the raw output ofmarkitdown --list-plugins.version()Returns the MarkItDown CLI version string (output ofmarkitdown --version).
-
Method Details
-
create
Creates a client with default settings (markitdownon thePATH). -
builder
Creates a new client builder. -
convert
-
convert
Converts a file to Markdown. -
convert
Converts in-memory bytes to Markdown by piping them to the tool's standard input. Because there is no filename, supplying anConversionOptions.Builder.extensionHint(String)or MIME-type hint is strongly recommended so MarkItDown can pick the right converter. -
convert
Converts the contents of a stream to Markdown by piping them to standard input. -
convertToFile
Converts a file and writes the Markdown directly tooutput(maps to the CLI-oflag). The output file is written by the MarkItDown process itself using UTF-8. -
version
Returns the MarkItDown CLI version string (output ofmarkitdown --version). -
isAvailable
public boolean isAvailable() -
listPlugins
Returns the raw output ofmarkitdown --list-plugins.
-