How to Format N-Triples RDF Data - Step by Step Guide
Input Your N-Triples Data
Start by adding your N-Triples data. Whether it's from a database export or a text file:
Example: Unformatted N-Triples Input
Here's what messy, unformatted N-Triples look like (hard to read):
<http://example.org/person/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> . <http://example.org/person/1> <http://schema.org/name> "Dr. Alice Johnson" . <http://example.org/person/1> <http://schema.org/email> "[email protected]" . <http://example.org/person/1> <http://schema.org/jobTitle> "Data Scientist" . <http://example.org/person/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
Automatic Validation & Formatting
As soon as you add your N-Triples, the formatter (powered by N3.js) cleans it up automatically. Here's what happens:
Example: The Same Triples, One per Line
The fourth triple gets its own line; nothing else changes:
<http://example.org/person/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> . <http://example.org/person/1> <http://schema.org/name> "Dr. Alice Johnson" . <http://example.org/person/1> <http://schema.org/email> "[email protected]" . <http://example.org/person/1> <http://schema.org/jobTitle> "Data Scientist" . <http://example.org/person/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
Export Clean N-Triples
Take the tidied N-Triples with you:
Example: Using Formatted N-Triples
Your formatted N-Triples are ready for:
Frequently Asked Questions
What is N-Triples format?
N-Triples is the plainest way to write RDF: one triple per line, every IRI spelled out in full inside angle brackets, and a full stop at the end. There are no prefixes or shortcuts, which is why triple stores like it for bulk loads and why diffs of .nt files are easy to read.
Does the formatter validate syntax?
Yes. N3.js reads your text in strict N-Triples mode, and the first problem is shown with its line and column and the line itself. Common slips get a plain explanation: a missing full stop, an unclosed string, a relative IRI such as <thing>, a Turtle prefix like xsd:integer, or a fourth term on a line, which makes it N-Quads.
Does formatting change my data?
No. Only the whitespace between terms and the line breaks change. IRIs, blank node labels like _:person1, escapes such as \u00e9, language tags and datatypes are copied exactly as you wrote them, so "8901240544102066246"^^<http://www.w3.org/2001/XMLSchema#integer> keeps every digit. Comments stay too. Before showing the result, the page reads it back and checks it holds the same triples as your input.
Why did some of my triples move to new lines?
N-Triples allows one triple per line. N3.js will accept two on the same line, but stricter readers such as Python's rdflib reject the file, so the formatter gives each triple its own line and tells you how many it split.
Can I convert N-Triples to other formats?
Yes. The RDF Format Converter turns N-Triples into Turtle, JSON-LD, N-Quads or RDF/XML, and it also goes the other way if you have Turtle or JSON-LD that you want as N-Triples.
Is my data uploaded anywhere?
No. Your triples are parsed and formatted in your browser and aren't sent to our server. Nothing is kept either: a reload starts with an empty editor. For very large dumps (hundreds of megabytes), a command-line tool such as Apache Jena's riot will be quicker than a browser tab.
Related: the RDF Format Converter for other RDF formats and the RDF Validator for Turtle, N-Quads and TriG files.
Related Tools
JSON to RDF Turtle
Convert JSON to RDF Turtle format for semantic web applications
RDF Turtle to JSON
Convert RDF Turtle format to JSON for easier processing
JSON-LD Validator
Validate JSON-LD syntax and context resolution
RDF Validator
Validate RDF Turtle syntax and structure
JSON-LD to RDF Turtle
Convert JSON-LD to RDF Turtle format for semantic web applications
RDF Format Converter
Convert between RDF formats (Turtle, N-Triples, RDF/XML, JSON-LD)