Convert lines of text to an array format

Sometimes you have a file with tens or hundreds of lines of text and you need to wrap each line with double quotes and a comma so that it can be easily put inside a javascript array. This can happen for example if your data is rows in a spreadsheet. Here’s how you can go from a list of lines to a quoted, comma separated list:

Use a code editor with search/replace functionality. I used Notepad++ for this example.

Open find/replace and make sure it’s in Regular Expression mode.

Type in the search field the following:

(.+)

Type in the replace field the following:

"$1",

Then simply hit replace all. You will go from a file looking like this:

23snaps
 4Chan
 8tracks
 Academia
 Adobe Connect
 Amikumu
 Amino apps
 aNobii
 AO3
 ASMALLWORLD
 Athlinks
 Badoo
 BAND
 Basecamp
 beBee
 Bitchute
 blind
 Blogger
 Bubbly
 Caffeine
 Care2
 CaringBridge
 Cellufun
 Chatroulette
 Classmates
 Clubhouse
 CollegeHumor
 Concept Board
 CouchSurfing
 Crunchyroll
 D-Tube
 Deviantart
 diaspora
 Digg
 Discord
 Discord
 Disqus
 Douban
 Drupal
 Eliademy
 Ello
 Elpha
 eToro
 Etsy
 Facebook
 Facebook
 Facebook
 Fark
 FilmAffinity
 Flickr
 Flixster
 Foursquare
 Foursquare Swarm
 Friendica
 Funny or Die
 Gab
 Gaia Online
 Gettr
 GIPHY
 Goodreads
 Google Docs
 Google Groups
 Google+
 Habbo
 Houseparty
 Imgur
 Influenster
 Instagram
 Instagram
 Instagram
 IRC
 italki
 Jodel
 Joomla
 Kakaotalk
 LBRY
 Likee
 Line
 LINE
 LinkedIn
 LinkedIn
 LiveJournal
 Locals
 Mastodon
 Medium
 Medium
 MeetMe
 Meetup
 MeWe
 Microsoft Messenger
 Minds
 Mix
 Mixi
 MocoSpace
 MyHeritage
 MySpace
 Naver
 News groups
 Nextdoor
 Ning
 Open Diary
 Parler
 Patreon
 Peanut
 PeerTube
 Periscope
 Phpbb forum
 Phpbb forum
 Pinterest
 Pinterest
 Podcasts (in general)
 Podio
 Quora
 Qzone
 Ravelry
 Reddit
 Reddit
 Regular websites
 Regular websites
 Renren
 ReverbNation
 Rumble
 Second Life
 Signal
 Simple Machines forum
 Skype
 Skyrock
 Slack
 Snapchat
 Snapchat
 Soundcloud
 SoundCloud
 Stack Exchange
 SteemIt
 Stellar
 StumbleUpon
 Suomi 24
 Tagged
 Telegram
 Telegram
 Tencent QQ
 The Dots
 the-dots.com
 Tik Tok
 Tinder
 Tribe
 Triller
 Tumblr
 Twitch
 Twitch
 Twitter
 Twitter
 Twitter
 Twoo
 Unsplash
 Untappd
 Valence
 Vero
 Viadeo
 Viber
 Vimeo
 Vine
 VK
 VK
 Voat
 VSCO
 Wattpad
 We Heart It
 WeChat
 Weibo
 WhatsApp
 WhatsApp
 Wikipedia
 Wikipedia
 WordPress
 WordPress
 WT Social
 Xanga
 Xing
 Yelp
 Youtube
 Youtube
 Youtube
 Yubo
 YY

To a file looking like this:

"23snaps",
 "4Chan",
 "8tracks",
 "Academia",
 "Adobe Connect",
 "Amikumu",
 "Amino apps",
 "aNobii",
 "AO3",
 "ASMALLWORLD",
 "Athlinks",
 "Badoo",
 "BAND",
 "Basecamp",
 "beBee",
 "Bitchute",
 "blind",
 "Blogger",
 "Bubbly",
 "Caffeine",
 "Care2",
 "CaringBridge",
 "Cellufun",
 "Chatroulette",
 "Classmates",
 "Clubhouse",
 "CollegeHumor",
 "Concept Board",
 "CouchSurfing",
 "Crunchyroll",
 "D-Tube",
 "Deviantart",
 "diaspora",
 "Digg",
 "Discord",
 "Discord",
 "Disqus",
 "Douban",
 "Drupal",
 "Eliademy",
 "Ello",
 "Elpha",
 "eToro",
 "Etsy",
 "Facebook",
 "Facebook",
 "Facebook",
 "Fark",
 "FilmAffinity",
 "Flickr",
 "Flixster",
 "Foursquare",
 "Foursquare Swarm",
 "Friendica",
 "Funny or Die",
 "Gab",
 "Gaia Online",
 "Gettr",
 "GIPHY",
 "Goodreads",
 "Google Docs",
 "Google Groups",
 "Google+",
 "Habbo",
 "Houseparty",
 "Imgur",
 "Influenster",
 "Instagram",
 "Instagram",
 "Instagram",
 "IRC",
 "italki",
 "Jodel",
 "Joomla",
 "Kakaotalk",
 "LBRY",
 "Likee",
 "Line",
 "LINE",
 "LinkedIn",
 "LinkedIn",
 "LiveJournal",
 "Locals",
 "Mastodon",
 "Medium",
 "Medium",
 "MeetMe",
 "Meetup",
 "MeWe",
 "Microsoft Messenger",
 "Minds",
 "Mix",
 "Mixi",
 "MocoSpace",
 "MyHeritage",
 "MySpace",
 "Naver",
 "News groups",
 "Nextdoor",
 "Ning",
 "Open Diary",
 "Parler",
 "Patreon",
 "Peanut",
 "PeerTube",
 "Periscope",
 "Phpbb forum",
 "Phpbb forum",
 "Pinterest",
 "Pinterest",
 "Podcasts (in general)",
 "Podio",
 "Quora",
 "Qzone",
 "Ravelry",
 "Reddit",
 "Reddit",
 "Regular websites",
 "Regular websites",
 "Renren",
 "ReverbNation",
 "Rumble",
 "Second Life",
 "Signal",
 "Simple Machines forum",
 "Skype",
 "Skyrock",
 "Slack",
 "Snapchat",
 "Snapchat",
 "Soundcloud",
 "SoundCloud",
 "Stack Exchange",
 "SteemIt",
 "Stellar",
 "StumbleUpon",
 "Suomi 24",
 "Tagged",
 "Telegram",
 "Telegram",
 "Tencent QQ",
 "The Dots",
 "the-dots.com",
 "Tik Tok",
 "Tinder",
 "Tribe",
 "Triller",
 "Tumblr",
 "Twitch",
 "Twitch",
 "Twitter",
 "Twitter",
 "Twitter",
 "Twoo",
 "Unsplash",
 "Untappd",
 "Valence",
 "Vero",
 "Viadeo",
 "Viber",
 "Vimeo",
 "Vine",
 "VK",
 "VK",
 "Voat",
 "VSCO",
 "Wattpad",
 "We Heart It",
 "WeChat",
 "Weibo",
 "WhatsApp",
 "WhatsApp",
 "Wikipedia",
 "Wikipedia",
 "Wordpress",
 "Wordpress",
 "WT Social",
 "Xanga",
 "Xing",
 "Yelp",
 "Youtube",
 "Youtube",
 "Youtube",
 "Yubo",