Generate JSON Schema from Maven POM XML

Infer JSON Schema from Maven POM files with dependency arrays, build configuration nesting, and property sections used in Java projects.

Real-World XML

Detailed Explanation

Maven POM.xml to JSON Schema

Maven POM (Project Object Model) files are the backbone of Java project configuration. Converting POM XML to JSON Schema is useful for validation, tooling, and configuration management.

Example POM

<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0.0</version>
  <packaging>jar</packaging>
  <properties>
    <java.version>17</java.version>
    <spring.version>6.1.0</spring.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>6.1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>5.10.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Key Schema Observations

  1. Version as number: <modelVersion>4.0.0</modelVersion> is detected as a number, while semantic versions like 1.0.0 are also detected as numbers due to the decimal format
  2. Properties section: <java.version>17</java.version> produces an integer type
  3. Dependency array: Multiple <dependency> elements form an array
  4. Dependency item schema: All dependency fields are merged into a unified schema

Generated Dependency Schema

{
  "dependency": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "groupId": { "type": "string" },
        "artifactId": { "type": "string" },
        "version": { "type": "number" },
        "scope": { "type": "string" }
      },
      "required": ["groupId", "artifactId", "version", "scope"]
    }
  }
}

POM-Specific Considerations

  • Maven POM has a well-defined structure with known sections (build, plugins, profiles, etc.)
  • The generated schema covers whatever sections are present in your sample
  • For a comprehensive schema, paste a POM with all sections populated
  • Dotted property names (java.version) are treated as single property names

Beyond POM

The same approach works for other Java/JVM configuration XML files: Gradle settings, Spring XML beans, Hibernate mapping files, web.xml, and Log4j configurations.

Use Case

When building POM file validators, Maven repository tools, or dependency management systems. The schema can validate that POM files contain the required structure before processing, or generate TypeScript types for POM manipulation tools.

Try It — XML to JSON Schema

Open full tool