---
title: "Json.NET: convert JSON string to XML or XML to JSON string"  
description: "Json.NET: convert JSON string to XML or XML to JSON string"  
author: "Jayden Bell"  
published: 2013-05-29  
updated: 2013-05-29  
canonical: https://www.mindstick.com/forum/928/json-dot-net-convert-json-string-to-xml-or-xml-to-json-string  
category: "json"  
tags: ["json"]  
reading_time: 1 minute  

---

# Json.NET: convert JSON string to XML or XML to JSON string

Hi Everyone,\
I started to use [Json.NET](https://www.mindstick.com/forum/1903/can-json-dot-net-handle-a-list-lt-object-gt) to convert a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) in [JSON format](https://www.mindstick.com/forum/158266/what-is-the-json-format) to object or vice-versa. I am not sure in the JSON.NET [framework](https://www.mindstick.com/forum/34615/software-framework-vs-library), is it [possible to convert](https://answers.mindstick.com/qa/96585/is-it-possible-to-convert-a-presentation-into-a-video-if-yes-how) a string in \
JSON to [XML](https://www.mindstick.com/blog/203/working-with-xml-data-in-sql-server) format and vice-versa?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi Jayden!\
Yes. Using the JsonConvert class which contains helper methods for this precise purpose:\
// To [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) an XML node contained in string xml into a [JSON](https://www.mindstick.com/forum/34446/convert-json-string-to-object) string XmlDocument doc = new XmlDocument();doc.LoadXml(xml);string jsonText = JsonConvert.SerializeXmlNode(doc);\
// To convert JSON text contained in string json into an XML nodeXmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json);


---

Original Source: https://www.mindstick.com/forum/928/json-dot-net-convert-json-string-to-xml-or-xml-to-json-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
