Key Takeaways
- Each guide starts from a free method you can try in Google Sheets before you install anything, so the technique can be checked on your own data before it becomes part of a recurring workflow.
- The Apps Script examples read and write the sheet once.
- Formula alternatives cover the common case while the script handles the awkward edges that arrive with a real export.
- Every example keeps its source columns.
Introduction
A vCard file carries one contact per card, but it is awkward to filter, deduplicate or share in a spreadsheet. A CSV table makes those jobs easy. The reverse is useful too: a clean sheet of contacts often needs to become a VCF file for a phone or a mail client.
This guide gives you two Apps Script functions. One reads VCF text from a cell and writes a CSV style table. The other reads a contact sheet and creates a VCF file in Google Drive.
The Shape of a vCard
A vCard begins with BEGIN:VCARD and ends with END:VCARD. Lines inside it carry keys such as FN for the full name, ORG for the company, EMAIL and TEL. A contact can hold several emails and several phone numbers.
Long values may be folded onto a second line that starts with a space. The parser unfolds those lines before it reads the keys, so a wrapped value is treated as one value.
The Ready-Made Apps Script
Open Extensions then Apps Script, paste the code below and save it. Put VCF text in cell A1 of a sheet and run vcfToCsv() to produce a table on a tab called VCF Output. Run csvToVcf() with columns named name, email, phone and org to create a VCF file in Drive.
/** Unfolds a VCF string and splits it into separate cards. */
function unfoldVcf_(text) {
const lines = String(text || "").replace(/\r/g, "").split("\n");
const unfolded = [];
lines.forEach((line) => {
if (line.indexOf(" ") === 0 && unfolded.length) {
unfolded[unfolded.length - 1] += line.slice(1);
} else {
unfolded.push(line);
}
});
const cards = [];
let current = null;
unfolded.forEach((line) => {
if (line === "BEGIN:VCARD") {
current = {};
return;
}
if (line === "END:VCARD") {
if (current) {
cards.push(current);
}
current = null;
return;
}
if (!current) {
return;
}
const colon = line.indexOf(":");
if (colon === -1) {
return;
}
const rawKey = line.slice(0, colon);
const key = rawKey.split(".").pop().split(";")[0];
const value = line.slice(colon + 1);
if (key === "EMAIL" || key === "TEL") {
current[key] = current[key] || [];
current[key].push(value);
} else {
current[key] = value;
}
});
return cards;
}
/** Reads VCF text from A1 and writes a CSV style table to a VCF Output tab. */
function vcfToCsv() {
const book = SpreadsheetApp.getActiveSpreadsheet();
const source = book.getActiveSheet().getRange("A1").getValue();
const cards = unfoldVcf_(source);
if (!cards.length) {
throw new Error("No VCARD blocks were found in cell A1.");
}
const rows = [["Name", "Emails", "Phones", "Organisation"]];
cards.forEach((card) => {
rows.push([
card.FN || "",
(card.EMAIL || []).join(";"),
(card.TEL || []).join(";"),
card.ORG || "",
]);
});
let out = book.getSheetByName("VCF Output");
if (!out) {
out = book.insertSheet("VCF Output");
}
out.clearContents();
out.getRange(1, 1, rows.length, 4).setValues(rows);
console.log("VCF cards converted: " + cards.length);
}
function escapeVcf_(value) {
return String(value || "").replace(/\\/g, "\\\\").replace(/,/g, "\\,").replace(/;/g, "\\;").replace(/\n/g, "\\n");
}
/** Reads columns name, email, phone and org and creates a VCF file in Drive. */
function csvToVcf() {
const sheet = SpreadsheetApp.getActiveSheet();
const values = sheet.getDataRange().getValues();
const header = values[0].map((cell) => String(cell).trim().toLowerCase());
const columnOf = (name) => header.indexOf(name);
["name", "email", "phone"].forEach((name) => {
if (columnOf(name) === -1) {
throw new Error("The header must include a " + name + " column.");
}
});
const blocks = [];
for (let r = 1; r < values.length; r += 1) {
const row = values[r];
const lines = ["BEGIN:VCARD", "VERSION:3.0"];
lines.push("FN:" + escapeVcf_(row[columnOf("name")]));
if (columnOf("org") !== -1 && row[columnOf("org")]) {
lines.push("ORG:" + escapeVcf_(row[columnOf("org")]));
}
const email = row[columnOf("email")];
const phone = row[columnOf("phone")];
if (email) {
lines.push("EMAIL:" + escapeVcf_(email));
}
if (phone) {
lines.push("TEL:" + escapeVcf_(phone));
}
lines.push("END:VCARD");
blocks.push(lines.join("\r\n"));
}
const file = DriveApp.createFile("contacts.vcf", blocks.join("\r\n"));
console.log("VCF file created: " + file.getUrl());
}
Both functions keep every email and phone number. The CSV direction joins repeated values with a semicolon, which is easy to split later with SPLIT if you need one row per number.
The VCF direction escapes commas, semicolons and backslashes as the format requires. That detail matters because an unescaped comma in a company name starts a new vCard property in some readers.
A Worked Example
| VCF lines | CSV row |
|---|---|
| FN:Marie Curie and EMAIL:marie@zephyrion.com and TEL:+447700900123 and ORG:Zephyrion | Marie Curie, marie@zephyrion.com, +447700900123, Zephyrion |
| FN:Isaac Newton and EMAIL:isaac@orbitra.co and EMAIL:i.newton@orbitra.co | Isaac Newton, isaac@orbitra.co;i.newton@orbitra.co, , |
The second row keeps both email addresses in one cell. Nothing is lost, and the semicolon gives you a clear delimiter when you split the cell later.
Why This Needs a Script
Google Sheets has no native vCard parser. You can extract one labelled value with a formula if the text is predictable:
=IFERROR(REGEXEXTRACT(A1,"EMAIL:(.*)"),"")
That works for a single email line in a single card. It does not handle repeated fields, folded lines or a file with several cards. Once the file has more than one contact, the script is the reliable route.
Where the Converter Stops
The converter does not validate the data inside a vCard. It will happily carry a malformed email into a CSV row. Run an email cleanup pass on the table before you upload it anywhere.
Some vCard files use properties such as ITEM1.EMAIL or custom fields from a CRM export. The script only reads the standard FN, ORG, EMAIL and TEL keys. Extra fields are ignored rather than written into the wrong column.
VCF files can carry photos and certificates as encoded blocks. Those are not included in the CSV table, because a spreadsheet cell is the wrong place for them.
Move Contacts Without Losing Fields
A vCard is a transport format and a CSV is a working format. Use the first function to get contacts into a sheet where they can be cleaned and compared, then use the second to send a reviewed list back out.
When the sheet contains the same contact twice under slightly different names, the next step is fuzzy matching. Flookup Data Wrangler scores the candidate pairs in the same spreadsheet.
Frequently Asked Questions
Where do I put the VCF text?
Paste the contents of a vCard file into cell A1 of a sheet, or use a cell per file and adapt the range in the function.
Does the parser keep more than one phone number?
Yes. Every TEL line is kept and multiple numbers are joined with a semicolon in one CSV cell.
How do I download the generated VCF?
The script creates the file in your Google Drive and prints its URL to the log. Open the log, then open the file from Drive.
Does it handle folded VCF lines?
Yes. A line that starts with a space is joined to the previous line before parsing, which is how long vCard values are wrapped.
Can formulas do the same job?
Not cleanly. Sheets has no native vCard parser, so Apps Script is the practical route for anything beyond a single field.