Python List Converter
Turn pasted values into Python.
Build the Python list
Python List Converter
// Your converted output will appear here.
Choose a list, a tuple or a set, and decide whether numbers and booleans become real Python literals — True, False and None, not the lowercase JSON spellings.
How to use the Python List Converter
Paste your values
One per line by default; switch the delimiter for comma or tab separated sources.
Pick the container
List for ordered, mutable data. Tuple when it must not change — a dict key, or a function returning fixed values. Set to drop duplicates and lose ordering.
Choose how values are typed
Strings quotes everything. Numbers emits bare numeric literals. Auto also converts true/false to True/False and null, none or nil to None.
Python List Converter examples
A Python list
Input
London Paris Tokyo
Output
cities = [ "London", "Paris", "Tokyo" ]
A tuple, including the single-element case
Input
London
Output
cities = ("London",)A one-element tuple needs its trailing comma, or the parentheses are just grouping. The tool adds it.
Python literals with type detection on
Input
1 2.5 true null name
Output
values = [ 1, 2.5, True, None, "name" ]
Auto mode maps true to True and null to None — the Python spellings, not the JSON ones.
Working with text to array python
List, tuple, or set
A list is mutable and ordered. A tuple is immutable and hashable, so it can be a dictionary key or a set member. A set deduplicates and discards order — wrong for anything positional, and exactly right for membership tests, where `in` is O(1) against a set and O(n) against a list.
The single-element tuple trap
("London") is not a tuple; it is a string in parentheses. Only the trailing comma makes it one: ("London",). This tool emits that comma automatically, which is the case people most often get wrong by hand.
Python is not JSON
Python writes True, False and None where JSON writes true, false and null. Pasting JSON straight into a .py file fails on exactly those three tokens. Auto mode maps them for you — which is also why json.loads() exists rather than eval().
Popular text conversion tools
JavaScript Array Converter
Turn a list or string into a JavaScript array with const, let or var, single, double or template quotes, and automatic number and boolean detection.
Text to JSON Array Converter
Use this free online text to JSON array converter to turn lines, lists, TXT files, or delimited values into valid pretty-printed or minified JSON.
String to Array Converter
Use this free online string to array converter to split text by commas, delimiters, whitespace, regex, or visible characters and copy matching code.
Numbers to Array Converter
Convert a list of numbers into an unquoted numeric array, sort it numerically, drop non-numeric values, and read the count, min, max, sum, mean and median.
Python List Converter FAQs
Python List Converter
Turn pasted values into Python. Choose a list, a tuple or a set, and decide whether numbers and booleans become real Python literals — True, False and None, not the lowercase JSON spellings.