Our Network


Coming Soon


Coming Later

CSV Column Sorter

World's Simplest CSV Tool

Free online CSV column sorter. Just upload your CSV file in the form below, specify which column you want to sort by, and the tool will automatically sort all the values in the CSV. In the tool options, you can choose the sorting method (alphabetical, numerical, by length, or complexity) and sorting order (increasing or decreasing). Additionally, you can specify a secondary column for sorting in cases of identical values in the primary column. Created by programmers from team Browserling.

CSV Column Sorter

World's Simplest CSV Tool

Free online CSV column sorter. Just upload your CSV file in the form below, specify which column you want to sort by, and the tool will automatically sort all the values in the CSV. In the tool options, you can choose the sorting method (alphabetical, numerical, by length, or complexity) and sorting order (increasing or decreasing). Additionally, you can specify a secondary column for sorting in cases of identical values in the primary column. Created by programmers from team Browserling.

Tool Options

Sort Column

Sort by this column (number).
Secondary sort position(s). (For example: "2" or "3, 5".)
Sort by this column (header).
Secondary sort name(s). (Enter one per line.)

Headers and Sort Order

Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.

Handle Incomplete Data

Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.

CSV Tidy Up

Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.

What Is a CSV Column Sorter?

This tool sorts columns of Comma-Separated Values (CSV) files. The program sorts data based on the selected column similar to the sort function in Excel or Google Sheets. Once you specify a column to sort, it rearranges all CSV rows so that the values in the chosen column are sorted. The column that needs to be sorted can be specified in two ways: using its position (number) or header value (name). Column numbering starts from 1 and then goes 2, 3, and so on. You can also use reverse numbering (numbering from the last column), which starts from -1 and then goes -2, -3, and so on. If there are multiple fields with identical values in the selected column, the program uses a stable sort algorithm and outputs these rows in their original order. However, you can activate secondary sorting in this case. In the "Secondary Sort Columns" option, you can enter positions of alternative columns to sort by in case of identical values in the primary column. For example, if you initially sort the CSV by column 1 and there are identical values, you can enter the following columns in the secondary sort option: "2, 3". This means: in case of identical values in the 1st column, sort by the 2nd column, and in case of identical values in the 2nd column, sort again by the 3rd. You can specify any number of secondary columns and they can be in any order. The same sorting rules can be applied to the header-based mode. For example, you can first sort the CSV by a column with the header name "city" and then input secondary sort columns with headers "street" and "postcode" (one per line). When a CSV is sorted, the CSV headers can be fixed at the top and not moved or sorted along with other values. Use the "Sort Headers" option to configure this behavior. The tool offers several sorting methods. The first method is alphabetical sorting. In this mode, the tool rearranges all column values in the order defined in the ASCII and Unicode tables. The second method is numerical sorting. In this mode, the tool sorts numbers from the smallest to the largest or vice versa. This mode supports big number arithmetic and can sort arbitrarily large values. The third method is sorting by length. In this mode, the tool arranges values from the shortest to the longest or vice versa. The fourth method is sorting by complexity. In this mode, the tool calculates entropy (unpredictability of characters) and arranges values from the easiest to the most complex or vice versa. As mentioned, the sorting order can be ascending or descending, and it can be adjusted in the options. Additionally, you can choose in the options whether sorting should be case-sensitive or not. Besides just sorting, the utility can also fix a corrupted CSV file. Specifically, if some fields are missing in the CSV file, you can leave them as they are or replace them with empty values or custom strings. Additionally, if the CSV contains comments, you can specify in the options which symbol starts comments (e.g., "#" or "//"), and if necessary, remove them. Furthermore, you can delete all empty lines from the CSV file to tidy it up. Csv-abulous!

What Is a CSV Column Sorter?

This tool sorts columns of Comma-Separated Values (CSV) files. The program sorts data based on the selected column similar to the sort function in Excel or Google Sheets. Once you specify a column to sort, it rearranges all CSV rows so that the values in the chosen column are sorted. The column that needs to be sorted can be specified in two ways: using its position (number) or header value (name). Column numbering starts from 1 and then goes 2, 3, and so on. You can also use reverse numbering (numbering from the last column), which starts from -1 and then goes -2, -3, and so on. If there are multiple fields with identical values in the selected column, the program uses a stable sort algorithm and outputs these rows in their original order. However, you can activate secondary sorting in this case. In the "Secondary Sort Columns" option, you can enter positions of alternative columns to sort by in case of identical values in the primary column. For example, if you initially sort the CSV by column 1 and there are identical values, you can enter the following columns in the secondary sort option: "2, 3". This means: in case of identical values in the 1st column, sort by the 2nd column, and in case of identical values in the 2nd column, sort again by the 3rd. You can specify any number of secondary columns and they can be in any order. The same sorting rules can be applied to the header-based mode. For example, you can first sort the CSV by a column with the header name "city" and then input secondary sort columns with headers "street" and "postcode" (one per line). When a CSV is sorted, the CSV headers can be fixed at the top and not moved or sorted along with other values. Use the "Sort Headers" option to configure this behavior. The tool offers several sorting methods. The first method is alphabetical sorting. In this mode, the tool rearranges all column values in the order defined in the ASCII and Unicode tables. The second method is numerical sorting. In this mode, the tool sorts numbers from the smallest to the largest or vice versa. This mode supports big number arithmetic and can sort arbitrarily large values. The third method is sorting by length. In this mode, the tool arranges values from the shortest to the longest or vice versa. The fourth method is sorting by complexity. In this mode, the tool calculates entropy (unpredictability of characters) and arranges values from the easiest to the most complex or vice versa. As mentioned, the sorting order can be ascending or descending, and it can be adjusted in the options. Additionally, you can choose in the options whether sorting should be case-sensitive or not. Besides just sorting, the utility can also fix a corrupted CSV file. Specifically, if some fields are missing in the CSV file, you can leave them as they are or replace them with empty values or custom strings. Additionally, if the CSV contains comments, you can specify in the options which symbol starts comments (e.g., "#" or "//"), and if necessary, remove them. Furthermore, you can delete all empty lines from the CSV file to tidy it up. Csv-abulous!


CSV Column Sorter Examples

Click to try!
click me

Sort CSV Alphabetically by the First Column

In this example, we sort CSV data alphabetically by the first column. The CSV consists of two columns, where the first column contains letters of the alphabet, and the second column represents the position of each letter in the alphabet. We specify the sort column by its position as "1" and sort it alphabetically in increasing order.

f,6 b,2 a,1 c,3 d,4 e,5
a,1 b,2 c,3 d,4 e,5 f,6
Required options
These options will be used automatically if you select this example.
Sort by this column (number).
Secondary sort position(s). (For example: "2" or "3, 5".)
Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.
Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.
Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.
click me

Sort Chemical Elements by Proton Count

In this example, we sort CSV data with chemical elements by the "protonNum" (proton number or proton count) column. We specify the name of this column in the options and choose the mode that sorts a CSV by the header. We also switch to the numerical sorting algorithm and output the CSV data sorted from the smallest proton number to the largest.

symbol,protonNum B,5 Be,4 C,6 F,9 H,1 He,2 Li,3 N,7 O,8
symbol,protonNum H,1 He,2 Li,3 Be,4 B,5 C,6 N,7 O,8 F,9
Required options
These options will be used automatically if you select this example.
Sort by this column (header).
Secondary sort name(s). (Enter one per line.)
Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.
Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.
Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.
click me

Multi-column Sorting of CSV by Length

In this example, we're working with a CSV file containing playing card suits and we sort it by length across multiple columns. First, we sort the data by the 1st column in decreasing order, moving values with the highest number of "♠" to the top. Then, we sort the data by the 2nd column, moving values with the highest number of "♣" to the top. Finally, we sort the data by the 3rd column, moving values with the highest number of "♥" to the top.

♠♠♠,♣♣,♥♥,♦ ♠♠♠♠,♣♣♣,♥♥,♦ ♠♠♠,♣♣,♥,♦ ♠♠♠,♣♣♣,♥♥,♦
♠♠♠♠,♣♣♣,♥♥,♦ ♠♠♠,♣♣♣,♥♥,♦ ♠♠♠,♣♣,♥♥,♦ ♠♠♠,♣♣,♥,♦
Required options
These options will be used automatically if you select this example.
Sort by this column (number).
Secondary sort position(s). (For example: "2" or "3, 5".)
Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.
Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.
Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.
click me

Sort a CSV by Two Columns

In this example, we sort CSV columns alphabetically in ascending order by the "leap" column. We specify this column in the options via its header name and add a secondary sort by the "year" column. As a result, the program puts all non-leap years at the top and then sorts the years from smallest to largest. We also activate the CSV cleaning options to remove comments starting with the "#" symbol and empty lines.

year,leap,start 2088,true,Fri 2035,false,Mon 2064,true,Wed 2040,false,Mon 2072,true,Sat #2033 2032,true,Thu 2080,false,Tue 2048,true,Fri
year,leap,start 2035,false,Mon 2040,false,Mon 2080,false,Tue 2032,true,Thu 2048,true,Fri 2064,true,Wed 2072,true,Sat 2088,true,Fri
Required options
These options will be used automatically if you select this example.
Sort by this column (header).
Secondary sort name(s). (Enter one per line.)
Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.
Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.
Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.
click me

Sort CSV by Complexity

In this example, we sort a CSV password file by the password's complexity in the second column. To do this, we choose the "sort by complexity" sorting method and decreasing sorting order. We specify the column containing passwords for sorting by its position "2". Additionally, we replace incomplete data (missing passwords) with a custom string "***".

login,password kitty,12345 doggo,ilovebones pizza gamer,contrOLler dream,dr%e$am!1
login,password dream,dr%e$am!1 gamer,contrOLler doggo,ilovebones kitty,12345 pizza,***
Required options
These options will be used automatically if you select this example.
Sort by this column (number).
Secondary sort position(s). (For example: "2" or "3, 5".)
Move headers along with other values when sorting.
Select CSV sort method.
Select CSV sort order.
Sort CSV columns using strict letter case.
Choose a method for handling incomplete CSV data.
String used in custom value mode for filling incomplete data.
Specify the symbol used to denote comments. (Activate the checkbox to remove them.)
Erase empty lines from the output CSV.

Pro tips Master online csv tools

You can pass input to this tool via ?input query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try!

https://onlinetools.com/csv/sort-csv-columns?input=f%2C6%0Ab%2C2%0Aa%2C1%0Ac%2C3%0Ad%2C4%0Ae%2C5&use-column-number=true&column-number=1&secondary-column-numbers=&sort-headers=true&sort-method=alphabetically&sort-order=increasing&case-sensitive=true&incomplete-format=set-custom-value&custom-value=x&remove-comments=true&comment-character=%2523&remove-empty-lines=true

All CSV Tools

Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!
Quickly convert a CSV file to a JSON data structure.
Quickly convert a JSON data structure to a CSV file.
Quickly convert a CSV file to an XML file.
Quickly convert an XML file to a CSV file.
Quickly convert a CSV file to a YAML file.
Quickly convert a YAML file to a CSV file.
Quickly convert a CSV file to a TSV file.
Quickly convert a TSV file to a CSV file.
Quickly convert a CSV file to evenly aligned text columns.
Quickly convert text columns to a CSV file.
Quickly encode CSV to base64.
Quickly decode base64 to CSV.
Quickly convert CSV to URL-encoding.
Quickly decode CSV from URL-encoding.
Quickly change the CSV column delimiter to a new symbol.
Quickly prepend columns at the beginning of a CSV file.
Quickly append one or more new columns at the end of a CSV file.
Quickly insert one or more new columns anywhere in a CSV file.
Quickly export one or more columns from a CSV file.
Quickly replace any column in a CSV file with a new one.
Quickly delete one or more columns from a CSV file.
Quickly swap two columns in a CSV file.
Quickly exchange columns with rows in a CSV file.
Quickly exchange rows with columns in a CSV file.
Quickly transpose a CSV file.
Quickly truncate columns in a CSV file.
Quickly left-trim and right-trim column values in a CSV file.
Quickly sort data in one or more CSV columns.
Quickly remove double quotes from all CSV fields.
Quickly wrap all CSV fields in double quotes.
Quickly change the character that CSV fields are wrapped in.
Quickly make sure the given CSV file doesn't have errors.
Quickly find rows and columns in CSV that are missing values.
Quickly fill missing CSV values with placeholder values.

Coming Soon

These CSV tools are on the way!
Edit CSV in the Browser

Edit the contents of a CSV file in a neat editor.

Deduplicate CSV Data

Remove duplicate rows in a CSV file.

Analyze CSV

Display detailed information about a CSV file.

Convert CSV to HTML

Convert a CSV file to an HTML table.

Convert HTML to CSV

Convert an HTML table to a CSV file.

Convert CSV to Markdown

Convert a CSV file to a Markdown table.

Convert Markdown to CSV

Convert a Markdown table to a CSV file.

Convert CSV to ASCII Table

Draw an ASCII table from CSV data.

Convert CSV to ANSI Table

Draw an ANSI table from CSV data.

Convert CSV to Unicode Table

Draw a Unicode table from CSV data.

Convert CSV to PDF

Convert CSV to a PDF document.

Convert PDF to CSV

Extract data from a PDF and create a CSV file.

Convert CSV to a Screenshot

Create a screenshot of CSV data.

Convert CSV to an Image

Draw a CSV file as a PNG, JPG or GIF picture.

Convert Image to CSV

Extract data from an image and create a CSV file.

Convert CSV to Excel

Convert a CSV file to an Excel spreadsheet.

Convert Excel to CSV

Convert an Excel spreadsheet to a CSV file.

Convert CSV to vCard

Convert a CSV file to a vCard file.

Convert vCard to CSV

Convert a vCard file to a CSV file.

Convert CSV to LaTeX

Convert CSV to a LaTeX table.

Convert CSV to SQL

Generate SQL insert queries from a CSV file.

Convert SQL to CSV

Create a CSV file from SQL query results.

Convert CSV to qCSV

Convert a CSV file to a qCSV (quoted CSV) file.

Convert qCSV to CSV

Convert a qCSV (quoted CSV) file to a CSV file.

Convert CSV to INI

Convert a CSV file to an INI file.

Convert INI to CSV

Convert an INI file to a CSV file.

Convert CSV to JSONL

Convert a CSV file to a JSONL (JSON Lines) file.

Convert JSONL to CSV

Convert a JSONL (JSON Lines) file to a CSV file.

Convert CSV to TXT

Convert a CSV file to a plain text file.

Convert TXT to CSV

Convert a plain text file to a CSV file.

Convert CSV to 0SV

Convert a CSV file to a null-separated values file (0SV).

Convert 0SV to CSV

Convert a null-separated values file (0SV) to a CSV file.

Convert CSV to SSV

Convert a CSV file to a semicolon-separated file (SSV).

Convert SSV to CSV

Convert a semicolon-separated file (SSV) to a CSV file.

Convert CSV to HSV

Convert a CSV file to a hash-separated file (HSV).

Convert HSV to CSV

Convert a hash-separated file (HSV) to a CSV file.

Convert CSV to PSV

Convert a CSV file to a pipe-separated file (PSV).

Convert PSV to CSV

Convert a pipe-separated file (PSV) to a CSV file.

Convert CSV to SQLite

Create an SQLite database from the given CSV file.

Convert SQLite to CSV

Export tables from an SQLite database as CSV files.

Convert CSV to GeoJSON

Convert a CSV file to a GeoJSON file.

Convert GeoJSON to CSV

Convert a GeoJSON file to a CSV file.

Merge CSV Files

Merge together two or more CSV files.

Compare Two CSV Files

Visually show the differences between two CSV files.

Diff Two CSV Files

Run the diff algorithm on two CSV files.

Find Data in CSV

Find CSV cells that contain certain data.

Filter CSV Cells

Return data in a CSV file that matches a pattern.

Slice CSV

Extract a slice from a CSV file.

Cut CSV

Cut a fragment from a CSV file.

Rotate CSV Columns

Move CSV columns to the left or right.

Rotate CSV Rows

Move CSV data rows up or down.

Sort CSV Rows

Sort the data in one or more CSV rows.

Shuffle CSV Columns

Randomly change the positions of CSV columns.

Shuffle CSV Rows

Randomly change the order of CSV rows.

Shuffle CSV Values

Randomly change the order of all CSV values.

Rename CSV Columns

Change the name of CSV columns.

Create a Random CSV

Generate a random CSV of any size.

Create an Empty CSV File

Generate a CSV file that contains nothing.

Create a Large CSV File

Generate a large CSV file for testing.

Create a Custom CSV File

Generate a custom CSV file with m rows and n columns.

Delete Empty CSV Columns

Remove CSV columns that are completely empty.

Delete Empty CSV Rows

Remove CSV rows that are completely empty.

Delete Empty CSV Values

Remove all fields in a CSV file that are empty.

Delete Empty CSV Lines

Remove all empty lines in a CSV file.

Remove CSV Separator

Delete the comma separator from CSV files.

Remove Extra CSV Commas

Delete extra commas around CSV values.

Delete CSV Comments

Delete comments (lines starting with # or //) from CSV files.

Delete CSV Header

Delete the column header from a CSV file.

Delete First CSV Line

Delete the first line from a CSV file.

Compress a CSV File

Minify a CSV file and remove unnecessary whitespaces.

Optimize CSV File Size

Reduce the file size of a CSV file.

Change CSV Encoding

Change the character encoding of a CSV file to UTF8 or ISO-8859-1.

Add Extra Spaces in CSV

Add extra spaces between CSV columns.

Convert CSV to a Matrix

Convert a CSV file to an m-by-n matrix.

Convert CSV to an Array of Arrays

Convert a CSV file to an array of arrays of fields.

Convert an Array of Arrays to CSV

Convert an array of arrays of fields to a CSV file.

Convert CSV Columns to a List

Create a list from one or more CSV columns.

Convert CSV Rows to a List

Create a list from one or more CSV rows.

Convert CSV Columns to an Array

Create an array from one or more CSV columns.

Convert CSV Rows to an Array

Create an array from one or more CSV rows.

Find CSV Dimensions

Find the number of rows and columns of a CSV file.

Count CSV Columns

Find the number of columns in a CSV file.

Count CSV Rows

Find the number of rows in a CSV file.

Sum CSV Columns

Find the sum of CSV columns.

Sum CSV Rows

Find the sum of CSV rows.

Average CSV Columns

Find the average value of CSV columns.

Average CSV Rows

Find the average value of CSV rows.

Add Color to CSV

Use different colors for CSV data, quotes, and commas.

Animate a CSV File

Animate CSV data by showing column after column.

Fix a Broken CSV

Automatically fix a broken CSV.

Add Errors to CSV

Introduce random errors to a CSV file for fuzz testing.

Anonymize CSV Data

Hide personal or sensitive information in a CSV file.

Censor CSV Data

Mask data in a CSV file.

Hide a Message in a CSV

Hide a secret message in a CSV.

Encrypt CSV

Encrypt a CSV file and hide information in it.

Decrypt CSV

Decrypt a previously encrypted CSV file and make it readable.

Visualize CSV

Create a visual drawing that shows the CSV structure.

Create a CSV File

Create a new CSV file in the browser.

Unleash Zalgo on CSV

Distort a CSV file by infusing it with Zalgo characters.

Purge Zalgo from CSV

Neutralize the chaotic Zalgo and restore CSV integrity.

CSV Viewer

Preview the contents of a CSV file in an interactive editor.


Subscribe!

Subscribe to our updates. We'll let you know when we release new tools, features, and organize online workshops.

Enter your email here


Feedback. We'd love to hear from you! 👋

Created with love by

We're Browserling — a friendly and fun cross-browser testing company powered by alien technology. At Browserling our mission is to make people's lives easier, so we created this collection of CSV tools. Our tools have the simplest user interface that doesn't require advanced computer skills and they are used by millions of people every month. Our CSV tools are actually powered by our web developer tools that we created over the last couple of years. Check them out!

49K
@browserling

Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!