Our team pastes multi-field records into a browser tool every day: an ID, a password, a 2FA secret, an email, a cookie string. Depending on who exported them, the fields are glued together with |, ----, tabs, colons or semicolons. We built a small browser-only formatter that splits these lines, pulls out one column and removes duplicates. These are the parsing decisions that mattered, with code you can copy.
1. Strong delimiters first, weak delimiters second
A cookie string like c_user=...; xs=... contains ;, and every URL contains :. If a line also has | or ----, those are almost certainly the real field separators. So delimiters get two tiers:
function detectSeparator(line) { const strong = ['----', '|', '\t'].find((sep) => line.includes(sep)); if (strong) return strong; const weak = line.match(/;|:(?!\/\/)|,/); return weak ? weak[0] : '|'; } - Strong (
----,|, Tab) rarely appear inside a value. If one is present, use it. - Weak (
;,:,,): take whichever appears first in the line. -
:(?!\/\/)is a negative lookahead. A colon followed by//is the scheme inhttps://, not a separator.
2. Split on colons without cutting URLs in half
String.prototype.split accepts a regex, so the same lookahead works when splitting:
function splitLine(line, sep = detectSeparator(line)) { return line.split(sep === ':' ? /:(?!\/\/)/ : sep).map((s) => s.trim()); } splitLine('100000000000001:DemoPass#01:https://example.com/p'); // → ['100000000000001', 'DemoPass#01', 'https://example.com/p'] 3. Extract the ID by trying the most specific shape first
The numeric ID can be the first field, part of a profile URL, or only present inside a cookie (c_user=). Search from the most specific shape to the least specific:
function extractId(line) { const link = line.match(/facebook\.com\/profile\.php\?(?:[^#&\s]*&)?id=(\d{5,30})/i); if (link) return link[1]; const cUser = line.match(/(?:^|[\s;,|:"'])c_user=(\d{5,30})/i); if (cUser) return cUser[1]; for (const pattern of [/----|\||\t|[,;]/, /----|\||\t|[,;:]/]) { const hit = line.split(pattern).map((s) => s.trim()).find((p) => /^\d{5,30}$/.test(p)); if (hit) return hit; } return ''; } - A profile link wins.
(?:[^#&\s]*&)?allows other query parameters beforeid=. - Next comes
c_user=, but only at the start of the line or right after a delimiter-like character, so a key such asxc_user=doesn't match. - Last, any field that is 5–30 digits. The first pass doesn't treat
:as a delimiter and the second pass does. A colon-delimited line still works, and a|line whose cookie contains:doesn't get split there. -
\d{5,30}keeps short numbers such as PINs out.
4. Remove duplicates without losing order
Use a Set to check for duplicates and an array to keep the original order:
function uniqueIds(text) { const seen = new Set(); const out = []; for (const line of text.split(/\r?\n/)) { const id = line.trim() && extractId(line); if (!id || seen.has(id)) continue; seen.add(id); out.push(id); } return out; } Duplicates are checked on the extracted ID, so 100000000000001|... and https://www.facebook.com/profile.php?id=100000000000001 count as the same record.
5. Known limitations
- A value that contains the strong delimiter breaks the columns.
id|Pa|ss|emailsplits into four fields, and quoting rules are the only reliable fix. The tool shows a preview of the first line's columns, so you can catch this before exporting. - Weak-delimiter detection is a heuristic.
id;pass:wordsplits on;because it comes first. If your data mixes both, choose the separator manually. - CSV export needs real escaping. If a cell contains
",,or a line break, wrap it in quotes and double any quotes inside it.
How this was tested
The four snippets were run with Node.js node:assert/strict in 9 assertion groups, and all passed. They covered:
- strong vs weak delimiter detection;
- splitting on colons without breaking URLs;
- getting the ID from a link, a cookie and a colon-delimited line;
- rejecting a 4-digit PIN;
- removing duplicates written in different ways;
- the
|-in-password limitation described above.
All inputs were made-up demo values, and no network requests were made.
Try it
The formatter runs entirely in your browser: nothing is uploaded or stored. Account Text Formatter. I work on WuYoo, the site that hosts it.
This post was drafted with AI assistance and checked against the tool's source code and the tests above.



