Skip to content

Use CARML from the CLI

carml-jar is the command-line tool for CARML. It needs Java 25 or newer.

It comes in two builds. carml-jar-rdf4j writes RDF with RDF4J and carml-jar-jena with Apache Jena. They take the same options and differ in the output formats they offer. The examples below write carml-jar-X.jar for whichever you use.

Run a mapping

java -jar carml-jar-X.jar map -m mapping.ttl -rsl input -of ttl -o output.ttl
Option Meaning
-m A mapping file, or a directory of mapping files. Repeatable.
-rsl The directory that source paths in the mapping are relative to.
-of The output format. The default is nq (N-Quads).
-o The output file. Without it the RDF goes to standard output.

Nothing but RDF is written to standard output. Logging goes to standard error and shows only errors unless you ask for more: -v adds a summary with the number of statements, -vv adds debug detail.

The exit code is 0 on success, 1 when the mapping fails and 2 for a mistake in the command line.

Prefixes

Turtle and TriG output has no prefixes unless you declare them with -p:

java -jar carml-jar-X.jar map -m mapping.ttl -of ttl -p ex=http://example.com/,foaf

ex=http://example.com/ declares a prefix inline. A bare name such as foaf is looked up in the prefix.cc list that ships with the CLI, or in your own JSON or YAML file given with -pm.

Reading standard input

A mapping can read standard input through an unnamed carml:Stream:

cat data.json | java -jar carml-jar-X.jar map -m mapping.ttl > output.nq

Plan before you run

plan reads a mapping and recommends how to run it, without opening any source:

java -jar carml-jar-X.jar plan -m mapping.ttl --source-iterations data.csv=12950390

For each triples map it prints the source, the joins, the evaluator it recommends, and whether the map qualifies for direct serialization. It ends with a map command that has the recommended options filled in.

The recommendation depends on source size. --source-iterations name=count gives the number of records in a source and can be repeated. -i asks for the missing counts interactively.

Large inputs

--spill-to-disk, --evaluator and --dedup are covered in Large inputs and Deduplication. --metrics is covered in Observability.

All options are listed in the CLI reference.