---
title: "Discussion on \"Convert A CSV To A JavaScript Array of Objects — The Practical Guide\" | Hashnode"
description: "Discussion on \"Convert A CSV To A JavaScript Array of Objects — The Practical Guide\". It's simpler than you may think 😉"
url: "https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Convert A CSV To A JavaScript Array of Objects — The Practical Guide](https://hasnode.byrayray.dev/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide?utm_source=hashnode&utm_medium=feed)

It's simpler than you may think 😉

Sep 15, 2022 · 8 min read · hasnode.byrayray.dev  
Updated Dec 1, 2022  
Read the article

-   [#csv](https://hashnode.com/tag/csv)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#webdev](https://hashnode.com/tag/webdev)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)

## Written by

[Dev By RayRay](https://hashnode.com/@devbyrayray)

@devbyrayray · Netherlands

  
[View profile](https://hashnode.com/@devbyrayray)

Tech Lead / Lead Developer in the 🇳🇱 https://byrayray.dev/

🚀 Tech Lead / Lead Developer 🔥 Writing about CSS, JavaScript, Typescript, Angular, Vue.js, Nuxt.js, Serverless functions, and a lot more web-related topics. https://byrayray.dev/

## Responses 2

Markdown supported · ⌘↵ to post

[TooMuchTofu](https://hashnode.com/@TooMuchTofu)

[Nov 11, 2022](https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b/comment/636d9fc54597d909de581c42)

Hey RayRay,

Thanks for this, it was super helpful with my project.

I had one small issue with \\r being inserted into my column 2 keys and values which sounds like it was the same as Mohd.

Here was my solution:

```
const csvArray = csvToArr(e.target.result, ",");
csvArray.value = JSON.stringify(csvArray, null, 2).replaceAll("\\r","");
```

Simply just use replaceAll to remove the '\\r's.

There is probably a nicer way to do that, but this is good enough for me.

Thanks again.

Bryon

[Dev By RayRay](https://hashnode.com/@devbyrayray)

[Nov 11, 2022](https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b/comment/636d9fc54597d909de581c42#reply-636dfe4480c99a14d29c68a6)

I'm happy that it was helpful to you!

Thanks for the suggestion, I'm gonna look into it. Did you use the data in the post? Or did you use your data? Maybe there is a difference in it.

[Mohd Shakree Elmi Azmee](https://hashnode.com/@shakreeelmi)

[Oct 17, 2022](https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b/comment/634d2493d3656a77ce8766af)

Hello,

I'm new to Javascript, after trying the above, I realize there is '\\r' at the end of the last column (including the rows). How do I fix this?

Thank you.

[Mohd Shakree Elmi Azmee](https://hashnode.com/@shakreeelmi)

[Oct 17, 2022](https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b/comment/634d2493d3656a77ce8766af#reply-634d2730d3656a77ce876732)

Nevermind, I got it working.

I used .replace to remove the \\r.

Thanks!

[Dev By RayRay](https://hashnode.com/@devbyrayray)

[Oct 19, 2022](https://hashnode.com/posts/convert-a-csv-to-a-javascript-array-of-objects-the-practical-guide/6322e5018350c8888bf3043b/comment/634d2493d3656a77ce8766af#reply-634fbe96770c93961f03be92)

[Mohd Shakree Elmi Azmee](https://hashnode.com/@shakreeelmi) I'm happy you got it working 👍 This perfectly fits in the process of being a developer right 😅
