Home
Technical Architecture of the vCard 4.0 Specification
The vCard format serves as the universal standard for the digital exchange of personal and organizational contact information. Formally designated as the Virtual Contact File (VCF), its modern iteration, vCard 4.0, is strictly governed by the Internet Engineering Task Force (IETF) under RFC 6350. This specification transitions the format from a simple text-based container to a robust, extensible data model designed for synchronized address books, mobile devices, and professional email clients.
The Foundation of RFC 6350 and vCard 4.0
The transition to vCard 4.0 marked a significant shift in how contact data is serialized. Unlike version 2.1, which was largely proprietary and fragmented, or version 3.0 (RFC 2426), which introduced standardized properties, vCard 4.0 prioritizes internationalization and structured data integrity.
A primary requirement of RFC 6350 is the mandatory use of UTF-8 encoding. In previous iterations, character set negotiation often led to data corruption when exchanging contacts between Western and Eastern systems. By enforcing UTF-8, the vCard 4.0 specification ensures that names, addresses, and notes containing non-ASCII characters remain consistent across all compliant parsers.
Core Syntactic Structure
Every vCard object follows a rigid structural envelope. The data stream must begin with a specific header and terminate with a corresponding footer. Any data outside this envelope is ignored by standard-compliant parsers.
- BEGIN:VCARD: The mandatory starting marker.
- VERSION:4.0: The version property, which must immediately follow the BEGIN marker in version 4.0.
- Properties: The body containing contact details.
- END:VCARD: The mandatory closing marker.
A minimal compliant vCard 4.0 entry requires at least the BEGIN, VERSION, FN (Formatted Name), and END properties. Without the FN property, the vCard is considered technically invalid under RFC 6350, as it lacks a displayable identifier for the entity.
Detailed Analysis of Property Components
The vCard specification utilizes a "property" system where each line represents a specific piece of information. A property line consists of an optional group, a name, parameters, and a value.
Syntax of a Content Line
The ABNF (Augmented Backus-Naur Form) for a vCard content line is structured as follows:
[[group "."] name *(";" param) ":" value CRLF]
The group prefix is used to associate related properties. For example, if a contact has multiple addresses and associated labels, grouping them as item1.ADR and item1.LABEL allows a parser to recognize they belong to the same physical location.
The FN and N Identification Properties
Identification properties are the most critical elements of the specification.
- FN (Formatted Name): This is a single text string representing the name as it should be displayed. In our implementation testing, we have observed that while
FNis mandatory, it can be derived from theNproperty, but modern applications prefer explicitFNvalues to handle cultural nuances in name ordering. - N (Name): This property provides a structured breakdown. The value is composed of five components separated by semicolons: Family Name; Given Name; Additional Names; Honorific Prefixes; Honorific Suffixes.
- Example:
N:Stevenson;John;Quincy;Dr.;Jr. - Technical Note: If a component contains a literal semicolon, it must be escaped with a backslash (
\;).
- Example:
Communications Properties: TEL, EMAIL, and IMPP
Version 4.0 introduced stricter requirements for communication properties, moving toward URI-based values.
- TEL (Telephone): In vCard 4.0, the telephone property preferably uses the
tel:URI scheme (RFC 3966). This allows for explicit handling of country codes and extensions. A common error in legacy systems is providing raw digits, which vCard 4.0 parsers may struggle to format if theTYPEparameter is missing. - EMAIL: A simple text value representing an electronic mail address. Multiple email addresses are supported through the use of the
PREFparameter to denote the primary contact method. - IMPP (Instant Messaging and Presence Protocol): This property accommodates handles for platforms like Jabber, Skype, or other messaging services using the
urivalue type.
Advanced Data Types and Property Parameters
The power of the vCard 4.0 specification lies in its parameters, which provide context to the properties.
The TYPE Parameter
The TYPE parameter is the most frequently used modifier. It specifies the sub-category of a property, such as identifying a phone number as "work" or "home." In vCard 4.0, multiple types can be assigned to a single property using a comma-separated list.
- Example:
TEL;TYPE="work,voice,video":tel:+1-555-555-1212
The PREF Parameter
Preference handling is crucial for automated systems. The PREF parameter accepts an integer value between 1 and 100, where 1 represents the highest preference. If a vCard contains three email addresses, the one with PREF=1 is typically selected as the default for outgoing communications.
The MEDIATYPE and VALUE Parameters
For properties that involve external data, such as PHOTO or LOGO, the MEDIATYPE parameter identifies the MIME type of the resource (e.g., image/jpeg). The VALUE parameter specifies whether the value is a direct URI or an inline Base64-encoded binary blob.
Observation from Development Experience: While inline Base64 encoding is supported, it significantly increases the VCF file size, often causing timeouts in mobile synchronization protocols. The best practice for modern vCard 4.0 implementation is to host images externally and provide a secure HTTPS URI.
Handling Technical Constraints: Line Folding and Escaping
The vCard format is a text-based protocol, which introduces specific challenges regarding long lines and special characters.
The 75-Octet Folding Rule
To ensure compatibility with older transport agents that may have line-length limits, RFC 6350 specifies that content lines should be folded to a maximum width of 75 octets.
- Folding: A long line is split by inserting a CRLF (Carriage Return + Line Feed) followed by a single white space character (space or horizontal tab).
- Unfolding: A parser must remove any CRLF sequence that is immediately followed by a space or tab.
This process is particularly tricky when dealing with multi-byte UTF-8 characters. If a fold occurs in the middle of a 3-byte UTF-8 sequence, the parser must correctly reconstruct the octets before decoding the character. Failure to do so results in "Mojibake" or corrupted text.
The Escaping Mechanism
Special characters that serve as delimiters in the vCard syntax must be escaped if they are part of the literal data value.
- Commas (,): Used to separate list items. Escaped as
\,. - Semicolons (;): Used to separate property components. Escaped as
\;. - Backslashes (): The escape character itself. Escaped as
\\. - Newlines: Must be represented as the literal string
\nor\N.
Delivery Addressing and Geographical Properties
The ADR property in vCard 4.0 is highly structured, similar to the N property. It consists of seven components:
- Post office box
- Extended address (e.g., apartment or suite number)
- Street address
- Locality (city)
- Region (state or province)
- Postal code
- Country name
Example: ADR;TYPE=work:;;123 Tech Lane;San Francisco;CA;94107;USA
Geographical Coordination (GEO)
The GEO property provides a URI representing the latitude and longitude of the contact. In v4.0, this follows the geo: URI scheme.
- Example:
GEO:geo:37.7749,-122.4194
This property is increasingly important for CRM (Customer Relationship Management) systems that perform proximity-based searching or mapping.
Organizational and Explanatory Properties
Beyond basic contact info, the specification allows for rich organizational context.
- ORG: Defines the organization name and organizational units. Components are separated by semicolons.
- TITLE: The job title or functional position.
- ROLE: The role or category of the entity within the organization.
- KIND: A property introduced in v4.0 to define the type of entity the vCard represents. Possible values include
individual,group,org(organization), andlocation. This helps parsers decide whether to treat the vCard as a person or a company.
Evolution and Version Compatibility
Understanding the differences between vCard versions is essential for developers maintaining legacy support while adopting modern standards.
| Feature | vCard 2.1 | vCard 3.0 (RFC 2426) | vCard 4.0 (RFC 6350) |
|---|---|---|---|
| Encoding | Varied (Charset param) | Varied (Charset param) | Mandatory UTF-8 |
| Line Delimiter | CRLF | CRLF | CRLF |
| Standard Status | De facto / Versit | IETF Proposed Standard | IETF Internet Standard |
| Image Handling | Base64 | Base64 or URI | URI (Preferred) or Base64 |
| Structured Name | Required | Required | Required |
| MIME Type | text/x-vcard | text/vcard | text/vcard |
| Group Support | Limited | Supported | Enhanced |
The Move from 3.0 to 4.0
The most significant change for developers moving to 4.0 is the removal of the LABEL property. In vCard 3.0, LABEL was a separate property for delivery addresses. In vCard 4.0, the label information is moved into a parameter of the ADR property itself.
- v3.0 Style:
LABEL;TYPE=WORK:123 Tech Lane... - v4.0 Style:
ADR;TYPE=work;LABEL="123 Tech Lane...":;;123 Tech Lane;...
Security and Privacy Considerations
Contact files often contain sensitive PII (Personally Identifiable Information). The vCard specification includes properties to help manage data currency and integrity.
- REV (Revision): A timestamp indicating the last time the vCard was updated. This is critical for synchronization engines to determine which version of a contact record is the "source of truth."
- UID (Unique Identifier): A persistent, globally unique identifier for the contact. In a distributed environment, the
UIDprevents duplicate records when merging address books from different sources. - KEY: Used to attach or link a public key (e.g., PGP) to the contact, facilitating secure communication.
Implementation Strategies for Modern Applications
When building a vCard generator or parser, we recommend adhering strictly to RFC 6350 while maintaining a "liberal input" policy for older versions.
- Strict Validation: Use a validator that checks for the mandatory
FNandVERSION:4.0sequence. - Handling Multi-value Parameters: Always quote parameter values that contain special characters or spaces. While RFC 6350 allows some unquoted values, quoting (e.g.,
TYPE="work,home") prevents parsing ambiguities. - Graceful Degeneracy: If a parser encounters an unknown
X-property (experimental properties), it should store the data rather than discarding it, as these are often used for custom app data (like social media profiles). - Encoding Binary Data: If you must include images, ensure the Base64 stream is folded correctly according to the 75-octet rule, or many parsers will throw a memory exception or fail to terminate the property.
Alternative Representations: jCard and xCard
While the VCF text format is the most common, the vCard 4.0 data model has been mapped to other formats to suit different development environments.
- xCard (RFC 6351): An XML representation of the vCard 4.0 data model. It provides a more verbose but easily verifiable structure for enterprise systems that rely on XML schemas.
- jCard (RFC 7095): A JSON representation. Given the ubiquity of JavaScript and REST APIs, jCard is becoming the preferred format for web-based contact management systems. It maps properties to arrays, making it highly accessible for modern frontend frameworks.
Summary
The vCard 4.0 specification (RFC 6350) represents the current pinnacle of contact data interchange. By enforcing UTF-8 encoding, standardizing URI-based communication properties, and refining the parameter system, it addresses the fragmentation issues that plagued earlier versions. For developers, implementation requires careful attention to the ABNF grammar, particularly regarding line folding and character escaping. As contact management moves toward highly synchronized, multi-platform ecosystems, adhering to this technical specification is non-negotiable for ensuring data integrity and interoperability.
FAQ
What is the difference between .vcf and .vcard files?
There is no functional difference. Both extensions refer to files following the vCard specification. .vcf is more common in Windows and legacy systems, while .vcard is sometimes used in Unix-like environments. The MIME type for both is text/vcard.
Why does my vCard 4.0 file fail to open in Outlook?
Microsoft Outlook has historically had inconsistent support for vCard 4.0 features, often preferring vCard 2.1 or 3.0. If compatibility with older versions of Outlook is required, developers often need to "downgrade" the output to version 3.0 or avoid using vCard 4.0-specific parameters like the LABEL parameter within ADR.
Can I add custom fields to a vCard?
Yes. The specification allows for experimental properties prefixed with X-. For example, X-SOCIAL-TWITTER:https://twitter.com/username. Most modern parsers will preserve these fields even if they don't have a specific UI element to display them.
How do I handle line breaks in the NOTE property?
Line breaks within a property value must be escaped as \n or \N. Do not use literal CRLF sequences within a value, as the parser will interpret the CRLF as the end of the property line unless it is followed by a space (indicating a fold).
Is vCard 4.0 backwards compatible?
Technically, no. A vCard 4.0 parser should be able to read 3.0 files with some adjustments, but a 3.0 parser will likely fail on a 4.0 file due to new parameters and the mandatory UTF-8 requirement without charset signaling.