Convert

Convert VCF to XML: 4 Methods for vCard to XML Conversion

XML (Extensible Markup Language) is still the standard data exchange format for many enterprise systems, SOAP APIs, configuration files, and legacy platforms. While JSON has become more popular for web APIs, XML remains essential for systems like Fritz!Box phone books, Microsoft Exchange imports, Salesforce metadata, and healthcare data interchange. If your contacts are stored in VCF (vCard) format and you need to feed them into an XML-based system, you need to convert VCF to XML.

The conversion requires choosing an XML schema. Unlike CSV where you just flatten fields into columns, XML gives you control over element nesting, attributes, and namespaces. This guide covers four methods to convert vCard contacts to XML, from a Python script that lets you define your own schema to online tools that handle everything automatically. If you need JSON output instead, see our VCF to JSON guide.

We have built VCF parsing tools at Univik since 2013 and handle XML export for users integrating contact data into enterprise workflows, phone systems, and database imports.

Two XML Formats for vCard Data

Before converting, decide which XML structure fits your target system. There are two common approaches, and choosing the right one first avoids reformatting later.

Custom Flat XML (Most Common)

Each contact becomes a <contact> element with child elements like <firstName>, <email>, and <phone>. This is the format most enterprise imports expect. It is easy to read, easy to transform with XSLT, and maps directly to database tables. Use this format unless your target system specifically requires xCard.

Example:

<contacts><contact><firstName>Jane</firstName><lastName>Doe</lastName><email>jane@example.com</email></contact></contacts>

xCard (RFC 6351, Standards-Compliant)

xCard is an IETF standard that represents vCard data in XML with full property-level fidelity. It uses the urn:ietf:params:xml:ns:vcard-4.0 namespace and preserves every vCard property, parameter, and value type. Use xCard only if you need lossless round-trip conversion back to VCF, or if your system explicitly requires RFC 6351 compliance.

Example:

<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0"><vcard><fn><text>Jane Doe</text></fn></vcard></vcards>

4 Methods to Convert VCF to XML

Method 1: Python Script (Customizable Schema)

Python gives you full control over the XML structure. The vobject library parses VCF files, and Python’s built-in xml.etree.ElementTree module generates well-formed XML without any additional dependencies.

1

Install the vobject library: pip install vobject

2

Save the following as vcf_to_xml.py:

import vobject, sys
from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom.minidom import parseString
vcf_file = sys.argv[1] if len(sys.argv) > 1 else "contacts.vcf"
with open(vcf_file, "r", encoding="utf-8") as f:
  vcf_data = f.read()
root = Element("contacts")
for card in vobject.readComponents(vcf_data):
  c = SubElement(root, "contact")
  if hasattr(card, "n"):
    SubElement(c, "firstName").text = card.n.value.given
    SubElement(c, "lastName").text = card.n.value.family
  if hasattr(card, "fn"):
    SubElement(c, "fullName").text = card.fn.value
  if hasattr(card, "email"):
    SubElement(c, "email").text = card.email.value
  if hasattr(card, "tel"):
    SubElement(c, "phone").text = card.tel.value
  if hasattr(card, "org"):
    SubElement(c, "organization").text = card.org.value[0]
xml_str = parseString(tostring(root)).toprettyxml(indent=" ")
with open("contacts.xml", "w", encoding="utf-8") as f:
  f.write(xml_str)
print(f"Converted {len(root)} contacts to contacts.xml")

3

Run it: python vcf_to_xml.py contacts.vcf

The output is a well-formed XML file with an XML declaration and proper indentation. You can then customize the element names to match your target system’s schema.

Method 2: Online VCF to XML Converter (No Code)

If you do not need a custom XML schema, then online converters handle the conversion in your browser.

1

Go to an online VCF to XML converter. ConversionTab (conversiontab.com/vcf/xml) processes files locally in the browser, so your contact data never leaves your device. Conholdate offers server-side processing with additional format options.

2

Upload your VCF file or paste vCard text. Some tools allow you to customize the XML element mapping before conversion.

3

Download the XML output. Copy the result or save as a .xml file. Browser-based tools that process locally are safer for sensitive contact data because the file stays on your device.

Method 3: VCF Converter Tool (GUI, Bulk files)

A dedicated VCF converter tool provides a graphical interface for converting VCF files to XML without writing code. This is the simplest option for non-developers who need to convert many files at once.

1

Load VCF files. Use Add Files or Add Folder to load your contacts. The tool previews all contacts before conversion.

2

Select XML as the output format. Choose which fields to include, set the output path, and click Export. The tool generates a well-formed XML file.

Method 4: Excel or Sheets (VCF to CSV to XML)

If you already have a VCF to CSV conversion workflow, you can add an XML export step. This is a two-stage process but works well if you also need to clean or filter the data before generating XML.

1

Convert VCF to CSV using any method from our VCF to CSV guide.

2

Open the CSV in Excel. Clean the data, remove duplicates, and filter contacts as needed.

3

Export as XML. In Excel, go to Developer tab, click Export. If you have an XML map defined, Excel exports the data as structured XML. Without an XML map, you can save as XML Spreadsheet 2003 format, which wraps the data in a Microsoft-specific XML structure.

VCF to XML Element Mapping

This table shows the standard mapping from VCF properties to recommended XML element names. Use these element names for a clean, readable XML structure that is easy to transform with XSLT or parse with any XML library.

VCF Property XML Element Example Output
FN <fullName> <fullName>Jane Doe</fullName>
N (given) <firstName> <firstName>Jane</firstName>
N (family) <lastName> <lastName>Doe</lastName>
EMAIL <email> <email type=”work”>jane@company.com</email>
TEL <phone> <phone type=”cell”>+1-555-0123</phone>
ORG <organization> <organization>Acme Corp</organization>
TITLE <title> <title>Engineer</title>
ADR <address> (with children) <address><street>123 Main</street><city>Boston</city></address>
URL <url> <url>https://example.com</url>
NOTE <notes> <notes>Met at conference</notes>
BDAY <birthday> <birthday>1990-05-15</birthday>

For contacts with multiple emails or phone numbers, use repeated elements with a type attribute: <email type="work">...</email><email type="home">...</email>. This preserves the TYPE labels from the VCF and follows standard XML conventions for multi-value fields.

Method Comparison Table

Criteria Python Script Online Tool Converter Tool Excel (CSV to XML)
Custom XML schema Full control Limited Predefined With XML map
xCard (RFC 6351) output With code Some tools No No
Multi-contact VCF Yes Depends Yes Yes
Handles vCard 4.0 Yes Varies Yes N/A (via CSV)
Technical skill needed Medium None None Low
Data stays local Yes Depends Yes Yes
Best for Custom integrations Quick one-off Bulk non-dev Already have CSV

When to Use XML Instead of JSON or CSV

XML is not always the best choice for contact data. However, there are specific scenarios where XML is the required or preferred format.

Use XML When

Your target system requires XML input (Fritz!Box phone books, SOAP APIs, Microsoft Exchange). You need to validate data against an XSD schema. You need XSLT transformations for different output formats. Your organization uses XML-based ETL pipelines. You are working with healthcare (HL7), financial (XBRL), or government systems that mandate XML.

Use JSON or CSV Instead When

You are building REST APIs or JavaScript frontends (use JSON). You need to import into spreadsheets, databases, or CRMs (use CSV). You want the smallest file size (JSON is smaller, CSV is smallest). Your team is more comfortable with JSON tooling. There is no schema validation requirement.

Common Problems and Fixes

1

XML output contains invalid characters. VCF NOTE fields sometimes contain characters that are invalid in XML (control characters like 0x00-0x08). Before writing to XML, strip these characters from text values. In Python: re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f]', '', text).

2

Ampersands and angle brackets break the XML. If a contact’s name or note contains &, <, or >, these must be escaped as &amp;, &lt;, and &gt;. Python’s ElementTree handles this automatically when you set element .text values. However, if you are building XML strings manually, use an XML library instead of string concatenation.

3

Multiple emails or phones create only one XML element. The basic Python script uses card.email.value which returns only the first email. To capture all values, iterate: for email in card.contents.get("email", []): and create a <email> element for each one.

4

XML file has no encoding declaration. Some parsers reject XML without an encoding declaration. Make sure the first line of your output is <?xml version="1.0" encoding="UTF-8"?>. Python’s minidom toprettyxml() includes this by default, but if you use tostring() alone, you may need to add it manually.

5

PHOTO data creates enormous XML files. VCF files with embedded base64 photos produce very large XML elements. If you do not need photos in the XML, skip the PHOTO property during conversion. Otherwise, consider storing photos as external files and referencing them with a <photoUrl> element instead of embedding the base64 data.

Frequently Asked Questions

How do I convert VCF to XML?

Use a Python script with the vobject library to parse VCF properties and write them as XML elements using ElementTree. If you prefer no code, use an online VCF to XML converter like ConversionTab that processes files in the browser.

What is xCard (RFC 6351)?

xCard is the IETF standard for representing vCard data in XML. It uses a specific namespace and preserves all vCard properties with full fidelity. However, most real-world XML imports use simpler custom schemas, so xCard is only needed for standards-compliant systems or lossless round-trip conversion.

Can I convert VCF to XML in Excel?

Not directly. Excel cannot open VCF files. You need to first convert the VCF to CSV, open the CSV in Excel, and then export as XML. This works but requires an XML map for custom element names.

Is there a difference between VCF to XML and VCF to JSON?

Both convert contact data to a structured text format. XML uses tags (<email>...</email>) while JSON uses key-value pairs ("email": "..."). Use XML for enterprise systems, SOAP APIs, and schema-validated workflows. Use JSON for REST APIs and JavaScript applications.

How do I handle special characters in the XML output?

Use an XML library (not string concatenation) to generate your XML. Libraries like Python’s ElementTree or Java’s DOM automatically escape ampersands, angle brackets, and other characters that would otherwise break the XML structure.

Conclusion

Last verified: February 2026. Python script tested with vobject 0.9.7 on Python 3.12. VCF files tested from iCloud, Google Contacts, Outlook, and Samsung exports across vCard 2.1, 3.0, and 4.0.

To convert VCF to XML, the Python script (Method 1) gives you full control over the XML schema and handles all vCard versions reliably. For a quick conversion without code, online tools (Method 2) or a VCF converter tool (Method 3) produce well-formed XML from any VCF file. If your data is already in CSV, the Excel XML export path (Method 4) adds one more step but lets you clean the data first.

Three things to remember: use an XML library (never string concatenation) to avoid broken output from special characters, choose flat XML for most enterprise imports and xCard only for standards-compliant systems, and skip PHOTO properties unless your target system needs embedded images.

About the Author

This guide is written and maintained by the Univik team, developers of file conversion and digital forensics tools since 2013. Our VCF parsers handle vCard 2.1 through 4.0 with full support for multi-value properties, TYPE parameters, and quoted-printable encoding. We have tested VCF to XML conversion against exports from over 15 platforms and verified output with multiple XML validators. Have a conversion issue we did not cover? Let us know.