
Learn how to convert a JSON file to XML format with Node.js.
JSON (JavaScript Object Notation) is widely used for data interchange due to its simplicity and lightweight structure. However, many enterprise systems, legacy tools, and integration workflows still require data in XML (eXtensible Markup Language) format. Converting JSON to XML becomes essential for compatibility and structured representation.
This tutorial demonstrates how to easily convert JSON files into XML using Node.js REST API, which offers a powerful and scalable cloud-based data transformation capabilities.
Data Conversion REST API
The Aspose.Cells Cloud SDK for Node.js simplifies spreadsheet and structured data transformations. It allows you to upload JSON files and convert them directly to various formats, including XML, with just a few API calls.
Key Features
- Convert JSON to XML, XLSX, HTML, CSV, and more.
- Auto-detect data structure and preserve schema.
- RESTful API access with secure OAuth 2.0 authentication.
- No need for Microsoft Excel or desktop installations.
- Support for cloud storage and third-party integrations.
📦 Getting Started
- Install SDK via npm:
npm install asposecellscloud --save
- Setup Your API Credentials: Create an account at Aspose.Cloud Dashboard and obtain your Client ID and Client Secret. For further details, you may consider visiting quick start article.
Convert JSON to XML Using Node.js
Here’s how to perform the JSON to XML transformation with Node.js:
Step 1: Initialize the API:
const { CellsApi, PostWorkbookSaveAsRequest } = require("asposecellscloud");
const cellsApi = new CellsApi("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
Step 2: Upload JSON File:
const fs = require("fs");
const path = require("path");
const jsonFilePath = path.resolve("data.json");
await cellsApi.uploadFile("data.json", fs.createReadStream(jsonFilePath));
Step 3: Convert JSON to XML:
const saveOptions = {
SaveFormat: "XML"
};
const request = new PostWorkbookSaveAsRequest({
name: "data.json",
newfilename: "converted/output.xml",
saveOptions: saveOptions,
isAutoFitRows: true,
isAutoFitColumns: true
});
await cellsApi.postWorkbookSaveAs(request);
console.log("JSON successfully converted to XML.");

A preview of JSON to XML conversion with Node.js REST API.
- The JSON file used in the above example cam be downloaded from input.json.
JSON to XML Conversion Using cURL
If you prefer command-line tools or CI/CD pipelines, you can convert files using cURL.
Step 1 – Generate Access Token:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Step 2 – Send JSON to HTML Conversion Request:
curl -X 'POST' \
'https://api.aspose.cloud/v3.0/cells/{sourceJSON}/SaveAs?newfilename={resultantXML}&isAutoFitRows=false&isAutoFitColumns=false&checkExcelRestriction=false' \
-H "accept: application/json" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d "{
\"SaveFormat\": \"xml\",
\"ClearData\": true,
\"CreateDirectory\": true,
\"EnableHTTPCompression\": true,
\"RefreshChartCache\": true,
\"SortNames\": true,
\"ValidateMergedAreas\": true,
\"MergeAreas\": true,
\"SortExternalNames\": true,
\"CheckExcelRestriction\": true,
\"UpdateSmartArt\": true,
\"EncryptDocumentProperties\": true
}"
Replace sourceJSON
with the name of input JSON file, resultantXML
with the name of resultant XML file and ACCESS_TOKEN
with JWT access token generated above.
Try Free JSON to XML Online Converter
Want to try before coding? Use our Online JSON to XML Converter to try the conversion directly in your browser.

Free online JSON to XML converter App.
📚 Additional Resources
Conclusion
Whether you’re modernizing legacy systems, building integrations, or preparing data for XML-based workflows, Aspose.Cells Cloud SDK for Node.js makes it easy to convert JSON to XML with minimal effort. The API is secure, scalable, and ideal for developers looking to automate data conversions in the cloud.
Start transforming structured data into XML today — all through a few lines of Node.js code.
Related Articles
We highly recommend visiting the following blogs: