Put the onions in a large bowl with the salt and mix together. Cover and leave overnight.
Rinse well in cold water and allow to dry as much as possible.
Pack the onions into sterilised jars.
Put the vinegar, chilli flakes and sugar into a pan and slowly bring to the boil to dissolve the sugar.
Pour the vinegar over the onions and seal the jars.
Store in a cool, dark cupboard for two weeks before eating.