What is MIME type "application/jsonl"?
A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.
The MIME type application/jsonl is for files that use the JSON Lines format. Each line holds one complete JSON object.
This setup is ideal for large datasets and streaming logs because programs can read one record at a time.
- Stream Processing: New records appear line after line.
- Incremental Handling: Data can be processed without loading the whole file.
- Efficiency: Simplifies parsing when working with continuous data feeds.
Files in this format often use the JSONL extension. Some applications, like those handling JSON-based 3D Tiles, also involve similar data handling.
More details about JSON Lines are available at jsonlines.org.
Associated file extensions
Usage Examples
HTTP Header
When serving content with this MIME type, set the Content-Type header:
Content-Type: application/jsonl
HTML
In HTML, you can specify the MIME type in various elements:
<a href="file.dat" type="application/jsonl">Download file</a>
Server-side (Node.js)
Setting the Content-Type header in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.setHeader('Content-Type', 'application/jsonl');
res.end('Content here');
}).listen(3000);
Associated file extensions
FAQs
What is the difference between application/json and application/jsonl?
Standard application/json requires the entire file to be a single valid JSON element (usually an array or object), which must be fully loaded to be parsed. In contrast, application/jsonl consists of multiple independent JSON objects separated by newlines. This allows for stream processing, where data can be read and parsed line-by-line without waiting for the whole file to download.
How do I configure my web server to serve .jsonl files correctly?
You need to explicitly map the extension to the MIME type in your server configuration. For Apache, add AddType application/jsonl .jsonl to your .htaccess file. For Nginx, add application/jsonl jsonl; inside your mime.types file or the types block in your config.
Can I parse application/jsonl data using JSON.parse() in JavaScript?
Not directly on the entire file string. Because application/jsonl contains multiple root objects, JSON.parse() will throw a syntax error. You must first split the string by newlines (e.g., data.split('\n')) and then iterate through the resulting array to parse each line individually.
Why does the browser download .jsonl files instead of displaying them?
Browsers natively understand standard JSON but often treat application/jsonl as an unknown binary or generic text type, triggering a download. To view them inline, you can set the server header Content-Disposition: inline or use a browser extension designed for JSON Lines formatting.
Is application/jsonl the only MIME type for this format?
While application/jsonl is the widely accepted standard for files using the .jsonl extension, you may occasionally see application/x-ndjson (Newline Delimited JSON) or application/x-jsonlines. However, application/jsonl is generally preferred for modern implementations following the jsonlines.org specifications.
What happens if I pretty-print data inside an application/jsonl file?
Pretty-printing (adding indentation and newlines for readability) breaks the JSON Lines format. The parsers rely on the newline character \n strictly acting as the delimiter between records. If a single JSON object spans multiple lines, the parser will fail or read incomplete data.
General FAQ
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.
MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.
How do I find the MIME type for a file?
You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.
Why are multiple MIME types listed for one extension?
Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.