---
title: "NodeToHTML"
description: "NodeToHTML"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/android/reference/nodetohtml"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-17"
---

# NodeToHTML

## NodeToHTML

NodeToHTML converts one text node of a JSON Rich Text Editor (JSON RTE) field to HTML. A text node is the leaf of a JSON RTE document. It is a JSON object with a text key, plus one key for each formatting mark such as bold. Use this class to

*   write the text of one node and its marks as HTML
*   check the HTML that an [Option](/docs/developers/sdks/content-delivery-sdk/android/reference/option) writes for each mark

NodeToHTML has one static method and no instances. Its constructor is private, so call [textNodeToHTML](/docs/developers/sdks/content-delivery-sdk/android/reference/nodetohtml#nodetohtml-textnodetohtml) on the class itself.

## textNodeToHTML

textNodeToHTML converts one JSON Rich Text Editor text node to HTML and applies each of its formatting marks through an Option.

```
Returns: String. The text node as HTML.
ValidationThere is no client-side validation.textNodeToHTML throws NullPointerException when nodeText is null, and when renderOption is null and the node has at least one mark key.A node without a text key returns an empty string, plus the HTML of any marks it has.BehaviorClient-side only. textNodeToHTML reads the JSON you pass and makes no request.textNodeToHTML first replaces each line break (\n) in the text with <br />.It then checks the mark keys in this order and calls renderOption.renderMark once for each key the node has: superscript, subscript, inlineCode, strikethrough, underline, italic, bold. A later mark wraps an earlier one.For the break key, it applies the break mark only when the text holds no <br /> after the line-break replacement.textNodeToHTML checks only that a mark key exists, not its value. A node with "bold": false still renders as bold.textNodeToHTML does not escape <, > or & in the text, so the HTML treats those characters as markup.See DefaultOption renderMark for the HTML tag that the SDK's implementation writes for each mark.ExampleBasic usage: convert a text node with two marksimport android.util.Log;

import com.contentstack.sdk.DefaultOption;
import com.contentstack.sdk.NodeToHTML;

import org.json.JSONException;
import org.json.JSONObject;

try {
    JSONObject textNode = new JSONObject()
            .put("text", "Summer sale")
            .put("bold", true)
            .put("italic", true);
    String html = NodeToHTML.textNodeToHTML(textNode, new DefaultOption());
    Log.d("Contentstack", html); // <strong><em>Summer sale</em></strong>
} catch (JSONException e) {
    Log.e("Contentstack", e.getMessage());
}Edge case: line breaks and a mark set to falseimport android.util.Log;

import com.contentstack.sdk.DefaultOption;
import com.contentstack.sdk.NodeToHTML;

import org.json.JSONException;
import org.json.JSONObject;

try {
    DefaultOption option = new DefaultOption();

    JSONObject twoLines = new JSONObject().put("text", "Line one\nLine two");
    Log.d("Contentstack", NodeToHTML.textNodeToHTML(twoLines, option)); // Line one<br />Line two

    // The bold key exists, so the text renders as bold even though its value is false
    JSONObject notBold = new JSONObject().put("text", "Regular").put("bold", false);
    Log.d("Contentstack", NodeToHTML.textNodeToHTML(notBold, option)); // <strong>Regular</strong>
} catch (JSONException e) {
    Log.e("Contentstack", e.getMessage());
}
```

Text node with a text key and mark keys.

Renderer that writes each mark, usually a DefaultOption.

## NodeToHTML | Android Delivery SDK | Contentstack

The NodeToHTML class in the Android Delivery SDK converts one JSON Rich Text Editor text node and its formatting marks to HTML.