NexaWrite .nwf File Format Specification

Version: 1.0

License: MIT License

Author & Maintainer: NexussphereQ

Website: nexussphereq.neocities.org

Overview

The .nwf (NexaWrite Format) is a JSON-based file format designed for saving documents created in the NexaWrite editor. It supports embedded media (images, audio, video) and rich text formatting, allowing self-contained, portable documents.

File Structure

The file is a UTF-8 encoded JSON file with the following top-level structure:

{
  "name": "Document Title",
  "author": "Author Name",
  "date": "ISO 8601 timestamp",
  "content": [ ... ]
}

Content Nodes

The content array contains nodes representing document content. Nodes can be of two types:

Text Node

{
  "type": "text",
  "text": "Sample text here"
}

Element Node

{
  "type": "element",
  "tag": "p",
  "attributes": {
    "class": "highlight"
  },
  "children": [ ... ]
}

Supported tags include but are not limited to: p, b, i, u, em, strong, h1–h6, img, audio, video, source, ul, ol, li, div, span, br.

Attributes are key-value pairs corresponding to HTML attributes. For media elements, the src attribute typically holds a base64 data URI embedding the media content.

Media Embedding

Images, audio, and video files embedded in the document must be included as base64-encoded data: URIs in the src attribute.

This ensures the document is fully self-contained without external dependencies.

Serialization and Deserialization

The NexaWrite editor serializes the editable HTML content into the described JSON format on saving, and rebuilds the DOM on loading from a .nwf file by parsing the JSON and recreating nodes recursively.

Security

To prevent injection of unsafe content, when importing HTML or JSON content, only a safe subset of tags and attributes are allowed.

Sources (src) must be validated to be data: URIs or HTTPS/HTTP URLs.

Example

{
  "name": "Sample Document",
  "author": "NexussphereQ",
  "date": "2025-07-02T10:00:00Z",
  "content": [
    {
      "type": "element",
      "tag": "p",
      "attributes": {},
      "children": [
        {
          "type": "text",
          "text": "This is a sample paragraph with an embedded image:"
        },
        {
          "type": "element",
          "tag": "img",
          "attributes": {
            "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."
          },
          "children": []
        }
      ]
    }
  ]
}

License

The NexaWrite .nwf format specification and associated code are released under the MIT License.

Contact and Source

Maintained by NexussphereQ.

Visit https://nexussphereq.neocities.org for more info.