Blog
Wild & Free Tools

Convert JSON Test Results to JUnit XML — Free Online

Last updated: March 2026 6 min read
Quick Answer

Table of Contents

  1. What JUnit XML actually needs
  2. Convert your JSON, then reshape
  3. Cucumber JSON to JUnit XML
  4. The attributes problem — why you can't just paste
  5. Which CI platforms expect JUnit XML
  6. Frequently Asked Questions

CI platforms (Jenkins, GitLab CI, CircleCI, GitHub Actions) show test pass/fail summaries when your pipeline produces JUnit XML. If your test framework emits JSON instead — Cucumber, Mocha with a JSON reporter, or a custom harness — you need a conversion step. This guide walks through the JSON-to-JUnit-XML shape so your CI picks up the results and a browser-based prototype workflow before you wire a proper reporter.

What JUnit XML Actually Needs

The JUnit XML format is a <testsuites> root with nested <testsuite> and <testcase> elements. Minimal skeleton:

<testsuites>
  <testsuite name="checkout" tests="3" failures="1" time="0.42">
    <testcase name="adds item to cart" classname="checkout.cart" time="0.12"/>
    <testcase name="applies discount" classname="checkout.cart" time="0.08">
      <failure message="expected 90 got 100">Assertion at cart.spec.js:42</failure>
    </testcase>
    <testcase name="calculates tax" classname="checkout.cart" time="0.22"/>
  </testsuite>
</testsuites>

CI readers key off the tests, failures, errors, and skipped attributes on <testsuite>, plus the name/time attributes on each <testcase>. Failures have a nested <failure> element with a message.

Convert Your JSON, Then Reshape

Step 1: paste your JSON test output into the converter, set the root element to testsuites, click Convert. You get well-formed XML — but not yet JUnit-shaped.

Step 2: hand-edit to match the JUnit structure. Our converter outputs element-only XML, but JUnit requires attributes (name="...", tests="..."). See our attributes guide for the workaround — short find-and-replace or a small XSLT.

This is prototyping, not production. If you need this in CI forever, use a real reporter library (junit-xml-reporter, cucumber-junit) that emits the correct shape directly.

Sell Custom Apparel — We Handle Printing & Free Shipping

Cucumber JSON to JUnit XML

Cucumber emits JSON by default. Convert for CI reporting:

The manual path is worth it when you've got a single failing pipeline to debug and don't want to add tooling. Don't ship a manual conversion step.

The Attributes Problem — Why You Can't Just Paste

JUnit XML relies heavily on attributes. Our converter outputs element-only XML. A JSON {"tests":3} becomes <tests>3</tests>, not tests="3" on the parent. For a one-time conversion, the fastest fix is find-and-replace:

s|<testsuite>\s*<name>([^<]+)</name>\s*<tests>([^<]+)</tests>|<testsuite name="\1" tests="\2">|

Or restructure the JSON to flatten attribute-target keys before converting. For repeated work, write a real reporter.

Which CI Platforms Expect JUnit XML

If your test framework doesn't emit JUnit natively, the quickest win is a reporter library. Fall back to JSON-to-XML conversion only for prototyping.

Prototype Your JUnit XML in 30 Seconds

Paste JSON test output, convert to XML, reshape to JUnit. No CI plugin install to debug one pipeline.

Open Free JSON to XML Converter

Frequently Asked Questions

Can CI tools read JSON test results directly?

Some can with plugins, but JUnit XML is the universal format. GitHub Actions reporters, GitLab CI, and Jenkins all default to JUnit XML. Converting JSON to JUnit XML unlocks the built-in test-summary UI without additional plugin hunting.

Does this converter produce valid JUnit XML directly?

No — it produces well-formed XML, but JUnit uses attributes (name="...", tests="3") which our tool outputs as child elements instead. You'll need a find-and-replace or small XSLT to reshape to JUnit format.

What's the fastest path to JUnit XML from Mocha?

mocha-junit-reporter. Install, add --reporter mocha-junit-reporter, done. Takes 2 minutes. Manual JSON-to-XML conversion is only worth it if you can't add dependencies.

Can I use this for a Postman/Newman test run?

Newman has a --reporters junit flag built in. Use that. JSON-to-XML conversion is only needed if you've got output from a framework with no JUnit reporter.

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