Recommended Free Tools
Use Array.prototype.join() to turn an array into a string in TypeScript. Pass a separator to control how the items appear: colors.join(', ') produces red, blue, green. The conversion runs at JavaScript runtime; TypeScript checks the types used in your code.
Use join() to choose the separator
join() returns a string containing the array elements, with the chosen separator between them. If you omit the separator, it uses a comma.
As an Amazon Associate I earn from qualifying purchases.
const colors: string[] = ['red', 'blue', 'green'];
const text = colors.join(', ');
// "red, blue, green"
TypeScript infers that text is a string, so an explicit : string annotation is unnecessary. Array types such as string[] describe the values at compile time; the conversion itself uses JavaScript’s array method. See the TypeScript Handbook for array type forms and primitive types.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choose a separator that fits the output you need:
| Code | Result |
|---|---|
['red', 'blue'].join() |
red,blue |
['red', 'blue'].join(', ') |
red, blue |
['red', 'blue'].join(' | ') |
red | blue |
['red', 'blue'].join('') |
redblue |
The separator appears between elements, not after the last element. An empty array joined with any separator returns an empty string. MDN’s join() reference documents the method and its default comma separator.
#1 Best Overall
What happens with empty, nullish, or nested values?
In a joined string, null, undefined, and empty array slots become empty fields—not the literal words null or undefined.
const values: (string | null | undefined)[] = ['a', null, undefined, 'b'];
values.join(', ');
// "a, , , b"
Nested arrays are converted recursively. The outer separator applies between the outer elements; nested arrays use commas internally, so their structure can look flattened in the resulting text.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
[[1, 2], [3, 4]].join(';');
// "1,2;3,4"
These behaviors, including empty slots and nested arrays, are described in MDN’s method reference.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFormat object arrays by selecting the fields you want
Joining objects directly usually does not produce useful labels. Map each object to the field intended for display, then join those strings.
type User = { name: string };
const users: User[] = [{ name: 'Ada' }, { name: 'Lin' }];
const names = users.map(user => user.name).join(', ');
// "Ada, Lin"
This makes the desired representation explicit instead of relying on default object coercion.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When should you use toString() instead?
For arrays, toString() produces the default comma-separated form: it calls join() without an argument. Use join() when you need to choose the delimiter or make that formatting choice clear in the code. String(array) also gives the default string conversion, so neither is a substitute for a deliberately formatted display string.
A display string is not necessarily a serialization format. If another system needs structured data, choose a format designed for that requirement rather than assuming comma-separated output preserves the array’s structure.
The TypeScript Handbook recommends lowercase primitive type names such as string rather than the special built-in type String. See Everyday Types.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




