TEXT FORMAT

N-Quads

N-Quads (file extension .nq, media type application/n-quads) is a line-based, plain-text serialization for encoding an RDF dataset. It was standardized as a W3C Recommendation on 25 February 2014, edited by Gavin Carothers within the W3C RDF Working Group (chaired by Guus Schreiber and David Wood), as part of the RDF 1.1 family of specifications. It is a strict superset of N-Triples: where an N-Triples document encodes a single RDF graph, N-Quads adds a fourth term to each statement to identify which named graph the triple belongs to, so a single file can carry a complete multi-graph dataset.

Each line is one statement terminated by a period: subject, predicate, object, and an optional graph label, separated by whitespace. Subjects and predicates are absolute IRIs in angle brackets or (for subjects) blank nodes written as _: labels; objects may additionally be literals, given as quoted strings with an optional @ language tag or ^^ datatype IRI (defaulting to xsd:string). A missing fourth term places the triple in the dataset's default graph. Because every statement is self-contained on its own line with no prefixes, nesting, or abbreviations, the grammar is trivial to parse and to generate incrementally.

That line-atomicity is N-Quads' main practical virtue. It is the preferred format for streaming, bulk export, and bulk import into triplestores, since a parser or loader can process one line at a time without buffering the whole document, and tools can split, sort, deduplicate, grep, or diff datasets with ordinary line-oriented utilities. Line-per-statement structure also makes it well suited to version control, where each quad is an independently trackable change. In the graph-conversion world it serves as a common lossless lowest-common-denominator interchange target that libraries such as RDFLib (Python), Jena/RIOT, and dotNetRDF read and write, alongside more compact dataset syntaxes like TriG and TriX.

The trade-offs are verbosity and readability: full IRIs are repeated on every line with no prefix mechanism, so files are large and awkward for humans compared with Turtle or TriG. The specification also notes it cannot serialize empty named graphs, since a graph is only implied by the statements that reference it. RDF 1.2 continues N-Quads and, together with RDF-star, extends it toward quoted-triple annotations.

Alternative Names: NQuads, NQ

File Extensions: .nq Mimetype: application/n-quads vRDF 1.1
FeatureN-Quads
Multiple Graphs per Document supported
Nodes supported
Undirected Edges not supported
Directed Edges supported
Hyperedges not supported
Mixed-directionality Edges not supported
Parallel Edges supported
Self-loops supported
Edges on Edges partial
Nested Graphs in Nodes not supported
Nested Graphs in Edges not supported
Nested Graphs in Graphs not supported
Node Labels not supported
Edge Labels supported
Attributes on Nodes supported
Attributes on Edges not supported
Attributes on Graphs not supported
Typed Edges supported

Tools(Read & Write)

Read-only Tools

Frequently Asked Questions

What is a N-Quads file?

A N-Quads file stores a graph — its nodes, edges and attributes — in the N-Quads format (also: NQuads, NQ). See the feature table above for what it supports.

How do I open a N-Quads file?

Open it in a graph tool that supports N-Quads, or convert it to a format your tool reads. With GraphInOut you can convert N-Quads to GraphML, DOT, Connected JSON and more, right in your browser.

How do I convert a N-Quads file to another format?

Use the Convert from N-Quads link above: upload or paste your N-Quads file (input preset to N-Quads), choose a target format and download the result — free, no install.