What is MIME type "application/ubjson"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

application/ubjson is a MIME type for files that use the Universal Binary JSON format. It encodes JSON-like data into a binary form, which helps reduce file size and speeds up processing.
This format focuses on efficient data serialization. It allows fast reading and writing of structured information between programs.
Files using this MIME type typically use the UBJ extension. For further details, visit the UBJSON Official Site.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: application/ubjson    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="application/ubjson">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/ubjson');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the application/ubjson MIME type used for?

The application/ubjson MIME type identifies content encoded in Universal Binary JSON (UBJSON). This is a binary format designed to be strictly compatible with JSON but optimized for smaller file sizes and faster parsing, making it ideal for high-performance APIs and data transfer.

Which file extension is associated with application/ubjson?

The standard file extension for this MIME type is .ubj. While it represents JSON-compatible data, it uses a binary structure, so it should not be saved with a standard .json extension unless specifically required by a unique implementation.

How do I configure Apache to serve .ubj files correctly?

To ensure Apache serves .ubj files with the correct MIME type, add the following line to your .htaccess file or main configuration: AddType application/ubjson .ubj. This prevents browsers or clients from misinterpreting the binary data as generic text.

Can web browsers display application/ubjson files natively?

No, most modern web browsers do not natively render UBJSON files like they do with standard text-based JSON or HTML. To display the data, a developer must fetch the file using JavaScript and decode it using a client-side UBJSON library.

When should I use application/ubjson instead of application/json?

You should use application/ubjson when network bandwidth or parsing speed is a critical constraint, such as in IoT devices or high-frequency trading. For general web APIs where human readability and ease of debugging are more important, standard application/json is usually preferred.

How do I add UBJSON support to Nginx?

In Nginx, you need to update your mime.types file or the specific server block configuration. Add the directive application/ubjson ubj; to map the extension to the MIME type, then reload Nginx to apply the changes.

How can I view the contents of a .ubj file?

Because .ubj files are binary, opening them in a text editor like Notepad will show unreadable characters. To view the structured data, you need to use a Hex Editor, a dedicated UBJSON viewer, or a script (using Python or Node.js) to convert the binary data back into readable text JSON.

Is application/ubjson compressed?

UBJSON is a binary encoding, which inherently makes it more compact than text JSON, but it is not a compression algorithm like GZIP. However, files served as application/ubjson can be further compressed using standard HTTP compression methods (like GZIP or Brotli) for maximum efficiency.

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.