Blog
Wild & Free Tools

Convert JSON to XML for Spring Boot — Prototype and Production Paths

Last updated: March 2026 7 min read
Quick Answer

Table of Contents

  1. Add Jackson XML to Spring Boot
  2. Annotations for attribute and wrapper control
  3. When browser preview beats a test run
  4. SOAP client from Spring Boot — the bigger picture
  5. Common Spring Boot JSON-to-XML pitfalls
  6. Frequently Asked Questions

Spring Boot apps often bridge between REST (JSON) and SOAP (XML) systems. Jackson's jackson-dataformat-xml module handles the serialization — add the dependency, annotate your DTOs, set produces = "application/xml", and Spring returns XML. For prototyping the target shape before you wire the controller, our browser converter is faster than writing a Spring test. This guide covers both paths.

Add Jackson XML to Spring Boot

One dependency:

<dependency>
  <groupId>com.fasterxml.jackson.dataformat</groupId>
  <artifactId>jackson-dataformat-xml</artifactId>
</dependency>

Spring Boot auto-configures an XmlMapper bean. Any @RestController method can now return XML:

@GetMapping(value = "/customer/{id}", produces = MediaType.APPLICATION_XML_VALUE)
public Customer getCustomer(@PathVariable String id) {
    return customerService.find(id);
}

Spring picks produces from the Accept header. Client sends Accept: application/xml, Spring returns XML. Client sends Accept: application/json, Spring returns JSON. Same endpoint, two formats.

Annotations for Attribute and Wrapper Control

Jackson XmlMapper annotations give you per-field control:

public class Customer {
  @JacksonXmlProperty(isAttribute = true)
  private String id;

  private String name;

  @JacksonXmlElementWrapper(localName = "addresses")
  @JacksonXmlProperty(localName = "address")
  private List<Address> addresses;
}

Produces <Customer id="C-3391"><name>Ana</name><addresses><address>...</address></addresses></Customer>.

This level of control is what makes Jackson production-grade. Our browser converter outputs element-only XML without wrappers — fine for preview, not a match for Jackson's output.

Sell Custom Apparel — We Handle Printing & Free Shipping

When Browser Preview Beats a Test Run

You're designing a new endpoint. Target XML shape is unclear — do attributes go on Customer or on Id? Should addresses be wrapped? Without knowing, you'd:

  1. Write the DTO with annotations.
  2. Write a test that hits the endpoint.
  3. Run tests.
  4. Compare output to target.
  5. Adjust annotations. Goto 3.

Each iteration is a compile + test run — seconds to minutes depending on your build. A browser preview replaces the loop for the first pass:

  1. Sample the JSON your service will produce.
  2. Paste into the converter.
  3. Compare the browser output to the target.
  4. Identify gaps (attributes, wrappers, namespaces).
  5. Write annotations once — no test loop.

Faster design time, same production outcome.

SOAP Client From Spring Boot — the Bigger Picture

If Spring Boot is the SOAP client (not server), you'll use Spring Web Services or an auto-generated JAX-WS stub. JSON-to-XML happens at the payload building step:

  1. Your Spring service receives REST JSON.
  2. You map the JSON to a SOAP request object (via Jackson or manual construction).
  3. Spring WS serializes to XML and sends to the SOAP endpoint.

The browser preview is handy for step 2 — knowing what the outgoing XML will look like before you wire the stub. Our SOAP XML guide covers the envelope wrapping.

Common Spring Boot JSON-to-XML Pitfalls

These are Jackson-specific. The browser tool doesn't reproduce any of them — it's for previewing the overall shape, not fine-tuning Spring's output.

Preview Your Spring XML Output

Paste sample JSON, see the element shape, then annotate your DTO once.

Open Free JSON to XML Converter

Frequently Asked Questions

Does Spring Boot need any config to serve XML?

Just the jackson-dataformat-xml dependency. Spring Boot auto-configures the XmlMapper and content negotiation. Set produces or let the Accept header drive it.

Can I use the browser tool instead of Jackson in production?

No — browser tools don't run inside your service. Jackson XmlMapper is the right production tool. Browser is for design-time preview only.

Why does Spring serialize my List as nested repeated tags?

Default Jackson wraps collections: .... Fix with @JacksonXmlElementWrapper(localName = "addresses") + @JacksonXmlProperty(localName = "address") on the field.

Does Spring Boot support WADL-style content negotiation?

Yes — out of the box. Client sends Accept: application/json or application/xml, Spring picks the right serializer. No extra config needed beyond the Jackson XML dependency.

Alicia Grant
Alicia Grant Frontend Engineer

Alicia leads image and PDF tool development at WildandFree, specializing in high-performance client-side browser tools.

More articles by Alicia →
Launch Your Own Clothing Brand — No Inventory, No Risk