Json To Vcf Converter
For simple JSON where keys match VCF fields directly:
jq -r '.[] | "BEGIN:VCARD\nVERSION:3.0\nFN:\(.name)\nTEL:\(.phone)\nEMAIL:\(.email)\nEND:VCARD\n"' contacts.json > contacts.vcf
This works but lacks escaping for special characters – use only for trusted data.
Convert structured contact data from JSON format into standard VCF (vCard) files, which can be imported into address books (Google Contacts, Outlook, iPhone, Thunderbird, etc.). json to vcf converter
function jsonToVcf(jsonData): vcfString = "" for each contact in jsonData.contacts: vcfString += "BEGIN:VCARD\n" vcfString += "VERSION:4.0\n"// FN is mandatory if contact.fullName exists: vcfString += "FN:" + escapeVcf(contact.fullName) + "\n" // N (structured name) if contact.lastName or contact.firstName: last = escapeVcf(contact.lastName or "") first = escapeVcf(contact.firstName or "") vcfString += "N:" + last + ";" + first + ";;;\n" // Phone numbers for each phone in contact.phoneNumbers: typeParam = "TYPE=" + phone.type if phone.type else "" vcfString += "TEL" + formatType(typeParam) + ":" + phone.number + "\n" // Emails for each email in contact.emails: typeParam = "TYPE=" + email.type if email.type else "" vcfString += "EMAIL" + formatType(typeParam) + ":" + email.address + "\n" // Addresses for each addr in contact.addresses: adrStr = "ADR" + formatType("TYPE=" + addr.type) + ":" adrStr += ";;" + escapeVcf(addr.street) + ";" + escapeVcf(addr.city) adrStr += ";" + escapeVcf(addr.state) + ";" + escapeVcf(addr.postalCode) adrStr += ";" + escapeVcf(addr.country) + "\n" vcfString += adrStr // Other fields if contact.organization: vcfString += "ORG:" + escapeVcf(contact.organization) + "\n" if contact.jobTitle: vcfString += "TITLE:" + escapeVcf(contact.jobTitle) + "\n" if contact.birthday: vcfString += "BDAY:" + contact.birthday + "\n" if contact.notes: vcfString += "NOTE:" + escapeVcf(contact.notes) + "\n" if contact.website: vcfString += "URL:" + contact.website + "\n" vcfString += "END:VCARD\n" return vcfString
function escapeVcf(str): // Escape special characters: , ; , : return str.replace("\", "\\").replace(";", "\;").replace(",", "\,").replace(":", "\:")
| Scenario | Why You Need It | |----------|----------------| | API → Phone | Export contacts from a backend API (JSON) to your Android/iOS address book. | | CRM Export | Many CRMs export JSON but import VCF. | | Data Migration | Moving from a custom database to Google Contacts or Outlook. | | Backup & Restore | Keep a readable JSON backup but convert to VCF for restoration. |
JSON:
[
"name": "Ada Lovelace",
"email": "ada@example.com",
"phone": "+441234567890",
"company": "Analytical Engine"
,
"name": "Alan Turing",
"email": "alan@example.com",
"phone": "+441234567891",
"company": "Bletchley Park"
]
VCF Output:
BEGIN:VCARD VERSION:3.0 FN:Ada Lovelace EMAIL:ada@example.com TEL:+441234567890 ORG:Analytical Engine END:VCARD
BEGIN:VCARD VERSION:3.0 FN:Alan Turing EMAIL:alan@example.com TEL:+441234567891 ORG:Bletchley Park END:VCARDFor simple JSON where keys match VCF fields
| Common JSON Key | VCF Property | Description |
| :--- | :--- | :--- |
| name, full_name | FN | Formatted name |
| first_name + last_name | N | Structured name (Last;First;) |
| phone, mobile, tel | TEL | Telephone number |
| email, email_address | EMAIL | Email address |
| company, org | ORG | Organization |
| title, job_title | TITLE | Job position |
| address, location | ADR | Physical address |
| url, website | URL | Website |
| photo, avatar (base64) | PHOTO | Embedded image | This works but lacks escaping for special characters