All these snakes everywhere! I've had enough, and have decided that I much prefer camels. Therefore, I want you to convert my snakes to camels for me.


Turn any snake_case string into a camelCase string.
Capitals should be returned to lowercase before the conversion occurs.

Test Cases

In: camel_case
Out: camelCase

In: curse_these_snakes
Out: curseTheseSnakes

In: i_promise_1234_is_not_my_password
Out: iPromise1234IsNotMyPassword

Out: aaaaaBbbbb


As per usual, standard loophole rules apply.
This is - shortest answer wins. Leading/trailing underscores (e.g _string_) are ignored.

Current Winners (subject to change)

Esoteric Language

Me, with -1 bytes.

Standard Language

Also me, with -2 bytes.

  • \$\begingroup\$ What about strings starting with an underscore? eg. _a \$\endgroup\$
    – IMP1
    Nov 19 '19 at 11:57
  • 1
    \$\begingroup\$ Very similar \$\endgroup\$
    – Jitse
    Nov 19 '19 at 12:00
  • \$\begingroup\$ Hm. My research couldn't seem to find that, so I apologise - should I remove the question? \$\endgroup\$
    – Corsaka
    Nov 19 '19 at 12:01
  • \$\begingroup\$ Similar but not the same in my opinion.. Here we have only snake to camel, and not tile convention at all, e.g. The first word is lower case. \$\endgroup\$
    Nov 19 '19 at 16:02

Python 3, 51 bytes

lambda s:s[0].lower()+s.title().replace('_','')[1:]

Try it online!

-4 bytes thanks to ReinstateMonica

  • \$\begingroup\$ Unless it introduces some edge case I'm not seeing, replace is shorter \$\endgroup\$
    – squid
    Nov 19 '19 at 12:12
  • \$\begingroup\$ @ReinstateMonica yep, fair. \$\endgroup\$
    – Jitse
    Nov 19 '19 at 12:15
  • \$\begingroup\$ Trailing underscores are removed. In case of leading underscore next char is removed. Try it online! \$\endgroup\$ Nov 20 '19 at 12:29
  • \$\begingroup\$ @YuriGinsburg Thanks, but a leading underscore is not valid snake_case input, so there's no need to handle it. \$\endgroup\$
    – Jitse
    Nov 20 '19 at 12:46
  • 1
    \$\begingroup\$ @YuriGinsburg This really very much depends on how you define 'ignored'. Since this challenge is already closed as a duplicate, I will leave it as is. \$\endgroup\$
    – Jitse
    Nov 20 '19 at 13:30

Ruby, 39 bytes


Try it online!

This does nothing to leading and trailing underscores.

  • \$\begingroup\$ Trailing underscore is removed by this code. \$\endgroup\$ Nov 20 '19 at 10:18
  • \$\begingroup\$ Is it? It's not for me. Here's a Try-It-Online where they all have trailing underscores. And they're not removed. \$\endgroup\$
    – IMP1
    Nov 20 '19 at 10:21
  • \$\begingroup\$ Sorry for mistype. Leading underscores are removed. \$\endgroup\$ Nov 20 '19 at 11:43
  • \$\begingroup\$ Also capitalisation is changed in case of leading underscore. Try it online! \$\endgroup\$ Nov 20 '19 at 12:11

Gema, 28 characters


Sample run:

bash-5.0$ gema '_?=@upcase{?};?=@downcase{?}' <<< 'i_promise_1234_is_not_my_password'

Try it online!


Not the answer you're looking for? Browse other questions tagged or ask your own question.