Convert JSON to XML

Convert JSON (JavaScript object notation) to XML (Extensible Markup Language). Control how attributes and values are parsed, remove or include namespaces, and configure more options to format the converted ouput data.

Options

Face with waiting expression Nothing to see yet!

Loading takeymakey...
TakeyMakey code
Want this tool to do something else? Edit the code below and make it do whatever you want.
import { XMLBuilder } from "https://cdn.jsdelivr.net/npm/fast-xml-parser@5.3.1/+esm"

export const take = () => [
  { label: "JSON", type: "json" },
  { label: "Options", type: "group", value: options },
]

export const make = ([json, options]) => {
  const builder = new XMLBuilder(options)
  return [{ type: "code", value: builder.build(json) }]
}

const options = [
  { key: "format", label: "Format output", type: "toggle", value: true },
  {
    key: "attributeNamePrefix",
    label: "Attribute name prefix",
    type: "text",
    inline: true,
  },
  {
    key: "attributesGroupName",
    label: "Attribute group name",
    type: "text",
    value: "attributes",
    inline: true,
  },
  {
    key: "suppressBooleanAttributes",
    label: "Suppress boolean attributes",
    type: "toggle",
  },
  { key: "suppressEmptyNode", label: "Suppress empty nodes", type: "toggle" },
  {
    key: "arrayNodeName",
    label: "Root array node name",
    type: "text",
    inline: true,
  },
  {
    key: "textNodeName",
    label: "Text node name",
    type: "text",
    value: "_text",
    inline: true,
  },
]