Convert XML to Properties

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

XML vs Java Properties File Format Comparison

Aspect XML (Source Format) Properties (Target Format)
Format Overview
XML
Extensible Markup Language

W3C standard markup language designed for storing and transporting structured data. Uses self-describing tags with a strict hierarchical tree structure. Widely used in enterprise systems, web services (SOAP), configuration files (Maven, Spring, Android), and data interchange between heterogeneous platforms.

W3C Standard Enterprise Data
Properties
Java Properties File

Simple key-value pair configuration format native to the Java ecosystem. Properties files use plain text with key=value syntax, one entry per line. They are the standard configuration mechanism for Java applications, Spring Boot (application.properties), internationalization (i18n), logging frameworks (log4j), and build tools (gradle.properties). Java's java.util.Properties class provides native read/write support.

Java Ecosystem Configuration
Technical Specifications
Standard: W3C XML 1.0 (5th Edition) / XML 1.1
Encoding: UTF-8, UTF-16 (declared in prolog)
Format: Tag-based hierarchical tree structure
Validation: DTD, XML Schema (XSD), RELAX NG
Extension: .xml
Standard: java.util.Properties (Java SE specification)
Encoding: ISO 8859-1 (default), UTF-8 (modern usage)
Format: Flat key=value pairs, one per line
Comments: # or ! prefix for comment lines
Extension: .properties
Syntax Examples

XML uses nested tags for structure:

<?xml version="1.0"?>
<project>
  <name>MyApp</name>
  <version>2.0</version>
  <dependencies>
    <dependency>spring-core</dependency>
    <dependency>hibernate</dependency>
  </dependencies>
</project>

Properties use flat key=value pairs:

# Project Configuration
project.name=MyApp
project.version=2.0
project.dependencies.0=spring-core
project.dependencies.1=hibernate
Content Support
  • Nested elements with attributes
  • Namespaces for vocabulary mixing
  • CDATA sections for raw content
  • Processing instructions
  • Entity references and DTD declarations
  • Schema validation (XSD, RELAX NG)
  • XPath and XQuery for data access
  • XSLT for transformations
  • Key=value pairs with string values
  • Comment lines (# or ! prefix)
  • Multi-line values with backslash continuation
  • Unicode escape sequences (\uXXXX)
  • Dot-notation for hierarchical keys
  • Variable interpolation (in Spring)
  • Profile-specific files (Spring Boot)
  • Native Java API (java.util.Properties)
Advantages
  • Self-describing with semantic tags
  • Strict validation with schemas
  • Platform and language independent
  • Mature ecosystem (20+ years)
  • Excellent for complex hierarchical data
  • XSLT enables powerful transformations
  • Industry standard for enterprise integration
  • Extremely simple and human-readable
  • Native Java support (java.util.Properties)
  • Fast parsing with minimal overhead
  • Easy to edit in any text editor
  • Standard for Spring Boot configuration
  • Git-friendly with clean line-by-line diffs
  • No closing tags or special syntax
Disadvantages
  • Verbose syntax (lots of closing tags)
  • Large file sizes compared to JSON/YAML
  • Complex to read and edit manually
  • Slower parsing than JSON
  • Security risks (XXE, billion laughs attack)
  • Flat structure (no native nesting)
  • Values are always strings (no types)
  • No standard schema validation
  • Default encoding is ISO 8859-1 (not UTF-8)
  • No support for complex data structures
Common Uses
  • Enterprise data exchange (SOAP, ESB)
  • Configuration files (Maven pom.xml, Spring, Android)
  • Document formats (XHTML, SVG, MathML, DOCX internals)
  • RSS/Atom feeds and sitemaps
  • Financial data (XBRL, FpML, FIX)
  • Healthcare (HL7, FHIR)
  • Spring Boot configuration (application.properties)
  • Java i18n / localization (messages_en.properties)
  • Logging configuration (log4j.properties)
  • Build tool settings (gradle.properties)
  • Database connection settings (JDBC URLs)
  • Application feature flags and settings
Best For
  • Enterprise system integration
  • Strict data validation requirements
  • Complex hierarchical data structures
  • Legacy system interoperability
  • Java application configuration
  • Spring Boot externalized configuration
  • Simple key-value settings
  • Internationalization and localization
Version History
Created: 1996 by W3C (Jon Bosak et al.)
XML 1.0: 1998 (W3C Recommendation)
XML 1.1: 2004 (Unicode 2.0+ support)
Current: XML 1.0 Fifth Edition (2008)
Status: Stable W3C Recommendation
Created: 1995 (part of Java 1.0, java.util.Properties)
XML variant: 2004 (Java 5, Properties.loadFromXML)
Spring Boot: 2014 (application.properties convention)
Current: Part of Java SE 21+ specification
Status: Stable, core Java API
Software Support
Java: JAXP, DOM, SAX, StAX, JAXB
Python: xml.etree, lxml, BeautifulSoup
.NET: System.Xml, XDocument, XmlReader
Tools: XMLSpy, Oxygen XML, xsltproc
Java: java.util.Properties (built-in)
Spring: @PropertySource, @Value, @ConfigurationProperties
Python: jproperties, configparser
IDEs: IntelliJ IDEA, Eclipse, VS Code (properties plugins)

Why Convert XML to Java Properties?

Converting XML files to Java Properties format simplifies complex hierarchical configuration into clean, flat key-value pairs that Java applications consume natively. XML configuration files like Spring's applicationContext.xml, Maven's settings.xml, and various enterprise configurations can be flattened into the .properties format that is simpler to read, edit, and manage in modern Java and Spring Boot applications.

This conversion is especially important for teams migrating from legacy XML-based configuration to modern Spring Boot applications that prefer application.properties or application.yml. Instead of manually rewriting configurations, you can convert XML directly to properties format, preserving all settings as dot-notation keys (e.g., spring.datasource.url, server.port).

Our converter flattens XML hierarchy into dot-separated property keys: nested elements like <database><host>localhost</host></database> become database.host=localhost. Attributes are included with appropriate key suffixes, repeated elements use indexed notation (items.0, items.1), and comments are generated to document the original XML structure.

Java Properties files are the simplest configuration format in the Java ecosystem. They require no special parser (java.util.Properties is built into every JVM), produce clean one-line-per-setting diffs in version control, and integrate seamlessly with Spring's @Value annotation and @ConfigurationProperties binding. The flat structure makes it immediately clear what each setting does.

Key Benefits of Converting XML to Java Properties:

  • Simplified Configuration: Replace verbose XML tags with clean key=value pairs
  • Spring Boot Ready: Output works directly as application.properties
  • Native Java Support: Read with java.util.Properties without any library
  • Easy Editing: Simple text format editable in any editor
  • Version Control Friendly: One setting per line produces clean Git diffs
  • Migration Path: Move from legacy XML config to modern properties-based setup
  • Environment Override: Properties can be easily overridden via environment variables

Practical Examples

Example 1: Spring Database Configuration

Input XML file (applicationContext.xml):

<beans>
  <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
    <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/mydb"/>
    <property name="username" value="admin"/>
    <property name="password" value="secret"/>
  </bean>
</beans>

Output Properties file (application.properties):

# DataSource Configuration
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=admin
spring.datasource.password=secret

Example 2: Log4j Logging Configuration

Input XML file (log4j2.xml):

<Configuration status="WARN">
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="info">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Output Properties file (log4j.properties):

# Logging Configuration
configuration.status=WARN
appender.console.type=Console
appender.console.name=Console
appender.console.target=SYSTEM_OUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{HH:mm:ss} [%t] %-5level %logger - %msg%n
rootLogger.level=info
rootLogger.appenderRef.console.ref=Console

Example 3: Maven Settings

Input XML file (settings.xml):

<settings>
  <localRepository>/home/user/.m2/repository</localRepository>
  <servers>
    <server>
      <id>nexus-releases</id>
      <username>deployer</username>
      <password>deploy123</password>
    </server>
    <server>
      <id>nexus-snapshots</id>
      <username>deployer</username>
      <password>deploy123</password>
    </server>
  </servers>
</settings>

Output Properties file (settings.properties):

# Maven Settings
settings.localRepository=/home/user/.m2/repository
settings.servers.0.id=nexus-releases
settings.servers.0.username=deployer
settings.servers.0.password=deploy123
settings.servers.1.id=nexus-snapshots
settings.servers.1.username=deployer
settings.servers.1.password=deploy123

Frequently Asked Questions (FAQ)

Q: What is XML format?

A: XML (Extensible Markup Language) is a W3C standard for structuring, storing, and transporting data. It uses custom tags with a strict hierarchical tree structure. XML is used in enterprise integration (SOAP), configuration files (Maven pom.xml, Spring, Android), document formats (XHTML, SVG, DOCX internals), financial data (XBRL), and healthcare (HL7). Unlike HTML, XML tags are self-describing and user-defined.

Q: What is a Java Properties file?

A: A Java Properties file (.properties) is a simple key-value configuration format used throughout the Java ecosystem. Each line contains a key=value pair, with # for comments. Java provides native support via the java.util.Properties class. Properties files are the standard configuration format for Spring Boot (application.properties), logging (log4j.properties), internationalization (messages.properties), and build tools (gradle.properties).

Q: How is XML hierarchy flattened to key-value pairs?

A: The converter uses dot-notation to flatten XML hierarchy. Nested elements become dot-separated keys: <database><host>localhost</host></database> becomes database.host=localhost. Attributes are appended to the key path, and repeated elements use numeric indices (items.0, items.1). This convention is compatible with Spring Boot's property binding.

Q: Can I use the output directly in Spring Boot?

A: Yes, the generated properties file uses dot-notation that Spring Boot understands natively. You can use it as application.properties or application-{profile}.properties. Spring's @Value("${key}") and @ConfigurationProperties annotations can directly bind to the generated keys. You may need to adjust some key names to match Spring Boot conventions.

Q: What happens to XML attributes during conversion?

A: XML attributes are included in the property keys. For example, <server id="main" port="8080"/> might produce server.id=main and server.port=8080. The attribute name becomes part of the dot-notation key, preserving all configuration data in the flat format.

Q: How are repeated XML elements handled?

A: Repeated elements at the same level are indexed numerically. For example, multiple <server> elements become servers.0.host=..., servers.1.host=..., and so on. This indexed notation is compatible with Spring Boot's list binding using @ConfigurationProperties.

Q: Should I use Properties or YAML for Spring Boot?

A: Both are fully supported by Spring Boot. Properties files are simpler, have native Java support, and produce cleaner Git diffs (one change per line). YAML supports nested structure and is more compact for complex configurations. For XML migration, properties is often the easier first step, as both XML and properties are flat when compared to YAML's indentation-based nesting.

Q: Can I convert large XML configuration files?

A: Yes, our converter handles XML files of any reasonable size. Complex configurations with deep nesting produce longer property keys but remain valid and readable. The output includes comment separators to organize related properties into logical groups based on the original XML structure.