If you have Office 365 Excel then use This array formula:

=TEXTJOIN(",",,TRIM(MID(SUBSTITUTE(A2,",",REPT(" ",99)),((LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)-ROW(1:INDEX(XFD:XFD,LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)))*99+1,99)))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

If one does not have Office 365 Excel then vba will probably be the only choice.

Answer from Scott Craner on Stack Overflow
🌐
Capitalize My Title
capitalizemytitle.com › home › tools › online comma separator – convert list to csv (column to comma)
Convert Column to Comma Separated List
Helpful if you have a column where the first letters in each row are capital, and you want a comma-separated list without capitals. Reverse list: Reverse the list that you entered so that you can have the values backwards.
🌐
Capitalize My Title
capitalizemytitle.com › home › tools › reverse list – list reverser tool
Reverse List - List Reverser Tool
Change any settings on the right side of the list reverser by selecting how you want the list to be modified. Delimiter: The delimiter is the value you want to separate items in your lists. You can choose from commas (the default), commas with spaces after, spaces, and others.
🌐
Online Tools
onlinetools.com › list › reverse-list
Reverse a List – Online List Tools
For example, the regex /[;,]/ will allow you to use items that are either comma- or semicolon-separated. The input and output list items delimiters can be customized in the options. By default, both input and output lists are comma-separated. Listabulous! With this utility, you can reverse the order of items in a list.
🌐
MrExcel
mrexcel.com › forums › question forums › excel questions
Reverse list of words in a text string separated by comma | MrExcel Message Board
February 7, 2011 - Function ReverseString(rngString As Range, Optional strDelim As String = ",") As String Dim vStrings As Variant, lngString As Long vStrings = Split(rngString, strDelim) For lngString = UBound(vStrings) To LBound(vStrings) Step -1 ReverseString = ReverseString & strDelim & vStrings(lngString) Next lngString ReverseString = Replace(ReverseString, strDelim, "", 1, 1) End Function above stored in standard module in VBE then
🌐
Google Support
support.google.com › docs › thread › 4266778 › reversing-comma-separated-lists
Reversing Comma Separated Lists - Google Docs Editors Community
April 15, 2019 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
TendersOnTime
tendersontime.com › tools › column-to-comma-separated-list
Column To Comma Separated List | Tools | TendersOnTime
16 hours ago - Our free comma separator tool automatically converts a column to a comma list or list to CSV (comma-separated values). Copy your column of data and watch the conversion happen. You can do the reverse and convert a delimited list to a column. You can use our comma separator tool to convert column lists to comma-separated value (CSV) lists quickly and easily.
Find elsewhere
Top answer
1 of 4
3

Here I do it with sed:

sed '/,/!b                                                   
s/\( *[^ ]*\)\(.*\)/\2,\n\1/;:t
s/\([^,]*,\)\(\n.*\)/\2\1/;tt
s/\n\(.*\),/\1/' <<\DATA
LABEL1
    .BYTE 01, 02, 03, 04, 05
    .BYTE 01, 02, 03        
LABEL1
    .BYTE 01, 02, 03, 04, 05
    .BYTE 01, 02, 03
DATA

OUTPUT

LABEL1
    .BYTE 05, 04, 03, 02, 01 
    .BYTE 03, 02, 01 
LABEL1
    .BYTE 05, 04, 03, 02, 01 
    .BYTE 03, 02, 01 

It checks for a comma on the current line. If there is !no comma, sed branches out of the script and autoprints the line. If the line does contain a comma sed does the following:

  1. It first prepares the line by s///ubstituting the following:
    • \( *[^ ]*\) - the first occurring sequence of zero or more spaces followed immediately by a sequence of zero or more not space characters referenced as \1 followed immediately by...
    • \(.*\) - everything else on the line referenced as \2...
    • ...with \2,\n\1
    • Note - using the \n escape in the right-hand s///ubstitution field like this is not fully portable. For a sed that does not support it, it can be done instead by substituting a literal newline for the n in the statement.
  2. It :defines a branch/test label called t.
  3. While it still can, sed s///ubstitutes:
    • \([^,]*,\) - A sequence of zero or more not comma characters then a single comma referenced as \1 followed immediately by...
    • \(\n.*\) - A sequence beginning with at least one \newline character followed by anything/everything remaining in pattern space referenced as \2...
    • ...with \2\1.
  4. If the previous s///ubstitution tests successful, sed branches back to the :test label and tries again.
  5. Last sed does a little cleanup and replaces:
    • \n\(.*\), - the first occurring \newline character and the last occurring comma...
    • \1 - ...with all that lies between.

As sed does the recursive replacement, the \newline delimiter walks backwards one comma-delimited field at a time. It stops the replacements when the \newline is the first character on the line. Here's a look at its progress through the recursive replacement process:

 01, 02, 03, 04, 05,\n    .BYTE$
 01, 02, 03, 04,\n    .BYTE 05,$
 01, 02, 03,\n    .BYTE 05, 04,$
 01, 02,\n    .BYTE 05, 04, 03,$
 01,\n    .BYTE 05, 04, 03, 02,$
\n    .BYTE 05, 04, 03, 02, 01,$

After its initial preparatory substitution, sed does not delimit on anything but commas and the inserted \newline character. So any kind of comma-separated values work fine. Here's the output from running your long bit through it:

ITINERARY_ARRAY_01
    .BYTE <ITINERARY_00A
    .BYTE <ITINERARY_01A
    .BYTE <ITINERARY_02A
    .BYTE <ITINERARY_03A
    .BYTE <ITINERARY_04A
    .BYTE <ITINERARY_05A
    .BYTE <ITINERARY_06A
    .BYTE <ITINERARY_07A
    .BYTE <ITINERARY_08A
    .BYTE <ITINERARY_09A
    .BYTE <ITINERARY_10A
    .BYTE <ITINERARY_11A
    .BYTE <ITINERARY_12A
    .BYTE <ITINERARY_13A
    .BYTE <ITINERARY_14A
;-------------------
ITINERARY_01E
    .BYTE $00, $07, $05, $03 
;-------------------
ITINERARY_01F
    .BYTE $00, $09, $07, $05, $03 
;-------------------
ITINERARY_01G
    .BYTE $00, $0D, $28 
;-------------------
ITINERARY_01H
    .BYTE $00, $13, $0F, $0D, $28 
;-------------------
ITINERARY_01I
    .BYTE $00, $11, $0F, $0D, $28 
;-------------------
ITINERARY_01J
    .BYTE $00, $1E, $20, $09, $07, $05, $03 
;-------------------
ITINERARY_01K
    .BYTE $00, $15, $13, $0F, $0D, $28 
;-------------------
ITINERARY_01L
    .BYTE $27, $1C, $1E, $20, $09, $07, $05, $03
    .BYTE $00
;---------------------
2 of 4
2

File revbytes2.awk:

#!/usr/bin/awk -f
BEGIN {
        FS=",? +"
}
NF>2 && match($0,"^ +\.BYTE ") {
        printf substr($0,1,RSTART+RLENGTH-1)
        for(i=NF;i>3;i--) printf $i", "
        print $3
        next
}
1

FS=",? +" makes awk recognise the space after .BYTE and the , plus space sequence between the bytes as field separator.

For each line this will look for lines with more than 2 fields starting with spaces followed by .BYTE and one space and rember the start and length of this prefix in RSTART and RLENGTH as side effect of the match(...) expression.

If this match is found and there are more than 2 fields, the prefix is cut from the original line using RSTART and RLENGTH and printed followed by the remaining fields in reverse order.

If the spaces plus .BYTE plus space prefix was not found or there were not more than 2 fields, the line will be printed as is. So this will be done for a .BYTE-line defining only one byte too, because there is nothing to reverse.

Test run:

$ diff -u$(wc -l <input) input <(awk -f revbytes2.awk input)
--- input       2014-10-19 06:04:48.280714146 +0200
+++ /dev/fd/63  2014-10-19 22:40:01.385538235 +0200
@@ -1,42 +1,42 @@
 ITINERARY_ARRAY_01
     .BYTE <ITINERARY_00A
     .BYTE <ITINERARY_01A
     .BYTE <ITINERARY_02A
     .BYTE <ITINERARY_03A
     .BYTE <ITINERARY_04A
     .BYTE <ITINERARY_05A
     .BYTE <ITINERARY_06A
     .BYTE <ITINERARY_07A
     .BYTE <ITINERARY_08A
     .BYTE <ITINERARY_09A
     .BYTE <ITINERARY_10A
     .BYTE <ITINERARY_11A
     .BYTE <ITINERARY_12A
     .BYTE <ITINERARY_13A
     .BYTE <ITINERARY_14A
 ;-------------------
 ITINERARY_01E
-    .BYTE $03, $05, $07, $00
+    .BYTE $00, $07, $05, $03
 ;-------------------
 ITINERARY_01F
-    .BYTE $03, $05, $07, $09, $00
+    .BYTE $00, $09, $07, $05, $03
 ;-------------------
 ITINERARY_01G
-    .BYTE $28, $0D, $00
+    .BYTE $00, $0D, $28
 ;-------------------
 ITINERARY_01H
-    .BYTE $28, $0D, $0F, $13, $00
+    .BYTE $00, $13, $0F, $0D, $28
 ;-------------------
 ITINERARY_01I
-    .BYTE $28, $0D, $0F, $11, $00
+    .BYTE $00, $11, $0F, $0D, $28
 ;-------------------
 ITINERARY_01J
-    .BYTE $03, $05, $07, $09, $20, $1E, $00
+    .BYTE $00, $1E, $20, $09, $07, $05, $03
 ;-------------------
 ITINERARY_01K
-    .BYTE $28, $0D, $0F, $13, $15, $00
+    .BYTE $00, $15, $13, $0F, $0D, $28
 ;-------------------
 ITINERARY_01L
-    .BYTE $03, $05, $07, $09, $20, $1E, $1C, $27
+    .BYTE $27, $1C, $1E, $20, $09, $07, $05, $03
     .BYTE $00
 ;---------------------

Comparing mawk and gawk output:

$ diff <(mawk -f revbytes2.awk input) <(gawk -f revbytes2.awk input)
gawk: revbytes2.awk:5: warning: escape sequence `\.' treated as plain `.'

Obvioisly no differences on stdout. Good!

The warning vanishes if you write "^ +\056BYTE " instead of "^ +\.BYTE " inside the match(...) expression.

Maybe someone using gawk frequently knows a better way to avoid the warning.

🌐
Delim
delim.co
Free Online Comma Separating Tool
Do you often need to take a spreadsheet of data and convert to a comma-delimited list? Be it for taking a list of zip codes or names to make an SQL query, or to take data from a CSV and be able to paste into an array. At delim.co we make that just a little easier. Enter your non-delimited data on the left, hit the button, and boom, separated data on the right.
🌐
Alteryx Community
community.alteryx.com › t5 › Alteryx-Designer-Desktop-Discussions › Reversing-a-Comma-Separated-String › td-p › 618353
Solved: Reversing a Comma Separated String - Alteryx Community
August 13, 2020 - Hi Everyone, Hope you are doing great. I'm actually stuck on one step where I need to reverse a comma separated string. My String looks like this: this, on, help, need, I I want the value this way: I, need, help, on, this Note: The no of comma separated values in each row is different. ...
🌐
YouTube
youtube.com › watch
Excel quickly reverse text order by space or comma or any separator - YouTube
You can easily reverse text order by space or comma or return carriage or all characters or by a separator you specify in Excel with one click using out powe...
Published   September 10, 2019
🌐
Lalit Kumar B
lalitkumarb.wordpress.com › 2015 › 04 › 10 › reverse-the-order-of-comma-separated-string-using-oracle-sql
Reverse the order of comma separated string using Oracle SQL | Lalit Kumar B
April 10, 2015 - You can have a look at “Split comma delimited strings in a table using Oracle SQL” to understand how string split works. Now, let’s see how to reverse the order of indices: SQL> WITH DATA AS( 2 SELECT 1 ID, 'word1,word2,word3' text FROM dual UNION ALL 3 SELECT 2 ID, '1,2,3' text FROM dual UNION ALL 4 SELECT 3 ID, 'a,b,c' text FROM dual 5 ) 6 SELECT ID, 7 listagg(text, ',') WITHIN GROUP ( 8 ORDER BY rn DESC) reversed_indices 9 FROM 10 (SELECT t.id, 11 rownum rn, 12 trim(regexp_substr(t.text, '[^,]+', 1, lines.COLUMN_VALUE)) text 13 FROM data t, 14 TABLE (CAST (MULTISET 15 (SELECT LEVEL FROM dual CONNECT BY LEVEL <= regexp_count(t.text, ',')+1 16 ) AS sys.odciNumberList ) ) lines 17 ORDER BY ID 18 ) 19 GROUP BY ID 20 / ID REVERSED_INDICES ---------- ------------------------------ 1 word3,word2,word1 2 3,2,1 3 c,b,a SQL>
🌐
Text Cleaner
textcleaner.net › home › reverse list
Reverse List Online: Reverse List with this Online tool
August 25, 2025 - Reverse Clear · Last Updated on August 25, 2025 · Convert Semicolon Separated List to Column · Column to Semicolon Separated List · Convert Comma Separated List to Column Online ·
🌐
Stack Overflow
stackoverflow.com › questions › 46926110 › reverse-list-of-words-in-a-text-string-separated-by-comma
excel - Reverse list of words in a text string separated by comma - Stack Overflow
October 25, 2017 - This would be better done with VBA, but if done without I suppose a monster such as this could solve this issue if all your lines would have the same number of of commas and semicolons:
🌐
Convert Town
convert.town › column-to-comma-separated-list
Convert Column to Comma Separated List Online
Convert column of data to comma separated list of data instantly using this free online tool.
🌐
Onsheets
onsheets.com › reverse-comma-separated-string-order
How to Reverse Order of a Comma-Separated String in Excel – On Sheets
July 25, 2023 - But, your dataset could contain hundreds and more comma-separated items and the script would still work. Here is the VBA script you should use along with the steps to implement it: Bring up the Excel VBA Editor by pressing Alt + F11 keys. Click the Insert button on the toolbar and choose Module. Into the new blank module, copy and paste the following VBA script: Sub ReverseCSVStrings() Dim inputRange As Range Dim outputRange As Range Dim inputCell As Range Dim outputCell As Range Dim originalString As String Dim reversedString As String Dim stringArray() As String Dim i As Long Set inputRange
Top answer
1 of 6
5

You can do this with awk:

#!/bin/bash

awk 'BEGIN{FS=",[ ]*"; OFS=", "}
    {
        for (i=NF; i>0; i--) {
            printf "%s", $i;
            if (i>1) {
                printf "%s", OFS;
            }
        }
        printf "\n"
    }'

Explanation of the script:

  • FS=",[ ]*";: The regex for Field Separator (delimiter for your input) matches a comma followed by zero or more spaces, so your input can be any of:
    • a, b, c, 1337, d, e
    • a,b,c,1337,d,e
    • a, (many spaces) b, c,1337,d, e
  • OFS=", ": The Output Field Separator (delimiter for your output) will be explicitly a comma followed by a space (so output looks consistent)
  • for (i=NF; i>0; i--) { ... }: NF means the Number of Fields in the current line. Here we iterate backwards, printing from the last field to the first field.
  • if (i>1) { ... }: Only print the OFS if it's not the last field in the output
  • printf "\n": new line.

Sample usage:

$ ./script_name < input_file > output_file
2 of 6
2

If your input is simple, and the number of columns is static, you could always go with a hardcoded awk solution:

awk -F, '{ print $6", "$5", "$4", "$3", "$2", "$1 }'

This assumes that you have 6 columns that are separated by a comma. If you have a "comma + space" delimiter, ,, you can use -F', ' instead of just -F,.

A straightforward example usage with output:

$ echo "a, b, c, 1337, d, e" | awk -F', ' '{ print $6", "$5", "$4", "$3", "$2", "$1 }'
e, d, 1337, c, b, a

With a file as input:

awk -F', ' '{ print $6", "$5", "$4", "$3", "$2", "$1 }' your_file

You can then redirect the output from that to another file by appending > reversed_columns; "reversed_columns" being the name of the new file in this case.

🌐
ExtendOffice
extendoffice.com › documents › excel › how to convert column list to comma-separated list in excel?
How to convert column list to comma-separated list in Excel?
July 3, 2025 - Excel doesn’t include a column-to-comma list function, but you can achieve it easily: use TEXTJOIN in Office 365/2019+, or CONCAT+IF in any version to streamline your data. As Excel's most advanced concatenation function, TEXTJOIN streamlines the process with its dual functionality - flexible delimiter selection and automatic empty cell management - providing the simplest solution for contemporary Excel users. 1. Select the cell where you want the comma-separated list to appear, enter the following formula: