Convert Json schema (jsons) to XML schema (XSD)
Branch: master
Clone or download
Latest commit 04d429a Aug 18, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Cleanup Aug 14, 2018
.gitignore Initial, major cleanup before 2.0 work Dec 8, 2017
.travis.yml Add code coverage run Dec 9, 2017
LICENSE Update license to reflect correct copyright owner Oct 10, 2015 Update Aug 18, 2018
pom.xml Preparing next dev cycle Aug 18, 2018


Maven Central License: MIT Coverage Status Codacy Badge Build Status

JSON-schema to XML schema converter written in Java.






try (final Reader r = ...)
  final Config cfg = new Config.Builder()
  final Document doc = Jsons2Xsd.convert(r, cfg);

Example input


Example output

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="" xmlns:x="" elementFormDefault="qualified" targetNamespace="">
  <complexType name="array">
      <element name="price">
          <restriction base="decimal">
            <minInclusive value="0" />
      <element name="name">
          <restriction base="string">
            <minLength value="5" />
            <maxLength value="32" />
      <element minOccurs="0" name="isExpired" type="boolean" />
      <element name="manufactured" type="dateTime" />

Support for non-standard types and formats

Ignore unknown JSON formats

final Config cfg = new Config.Builder()

Register custom JSON formats

final Config cfg = new Config.Builder()
    .customTypeMapping(JsonSimpleType.INTEGER, "int64", XsdSimpleType.LONG)
    .customTypeMapping(JsonSimpleType.INTEGER, "int32", XsdSimpleType.INT)
    .customTypeMapping(JsonSimpleType.STRING, "ext-ref", XsdSimpleType.STRING)

Register non-JSON types

final Config cfg = new Config.Builder()
    .nonJsonTypeMapping("date-time", XsdSimpleType.DATE_TIME)
    .nonJsonTypeMapping("int", XsdSimpleType.INT)