XML Input

Ruby Output

What Is XML to Ruby?

Ruby uses REXML or Nokogiri for XML. This tool generates Ruby classes from your XML. The W3C XML spec defines the format; conversion runs in your browser. Nothing is sent to a server.

How to Use This Tool

1

Paste or Upload XML

Paste XML or upload a file. Set class name and package (module) in the config.

2

Review Ruby Output

The right panel shows generated classes. Use REXML or Nokogiri to parse and populate.

3

Copy or Download

Use Copy or Download. For JSON to Ruby, use JSON to Ruby. For XML formatting, use XML Formatter.

When XML to Ruby Helps

When building Rails apps that consume SOAP, RSS, or XML APIs, generate typed classes here. Use REXML (standard library) or Nokogiri for parsing.

Frequently Asked Questions

REXML vs Nokogiri?

REXML is in the standard library. Nokogiri is faster and has XPath. Both parse XML into a tree.

Is my data sent anywhere?

No. Generation runs in your browser.

XML to Ruby Examples

Here is an example of generating Ruby classes from XML.

Example: Subscriber record

XML input:

Input

Generated Ruby output:

Output

Related Tools

REXML. Nokogiri. W3C XML spec. MDN DOMParser. JSON spec.